English 中文(简体)
获取当前职位上像当前用户一样的用户状态
原标题:Get current users like status on posts

使用“me/home”图表 API 调用用户的Facebook新闻,

现在,我一直在尝试许多方法,这些方法可以像列一样查询该邮政,并检查当前用户是否喜欢显示状态的邮件。基本上,我正在设置一个可以表示用户喜欢该邮件的图示。

我无法真正公布我迄今尝试过的任何代码,只是因为其中没有一个是有效的。而且相信我,我尝试过许多方法。

如果有人能至少证明我方向正确,我将不胜感激。

这是我最近一次尝试查询类似列, 并将结果与当前用户的 ID 比较:

这个代码是我正在检查相似点数并将其添加到一个阵列列表中。 这也是我运行查询以获取类似点数的地方 。

// GET THE POST S LIKES COUNT

    if (json_data.has("likes")) {
        JSONObject feedLikes = json_data.optJSONObject("likes");
        String countLikes = feedLikes.getString("count");
        postLikesCountArrayList.add(countLikes);

        // TEST STARTS

        // QUERY THE LIKES COLUMN TO CHECK YOUR LIKE STATUS ON A POST

        Bundle params = new Bundle();
        params.putString(Facebook.TOKEN, Utility.mFacebook.getAccessToken());
        Utility.mAsyncRunner.request(finalThreadID + "/likes&limit=200", params, new LikesListener());

        // TEST ENDS
        } else {
            String countLikes = "0";
            postLikesCountArrayList.add(countLikes);
        }

这个代码块是收听器( 同一活动的一个精密类), 检查结果 :

private class LikesListener extends BaseRequestListener {
        @Override
        public void onComplete(final String response, final Object state) {

            try {
                JSONObject JOLikes = new JSONObject(response);

                JSONArray JALikes = JOLikes.getJSONArray("data");

                for (int i = 0; i < JALikes.length(); i++) {
                    JSONObject JOTemp = JALikes.getJSONObject(i);

                    if (JOTemp.has("id"))   {
                        String getTempID = JOTemp.getString("id");

                        if (getTempID.equals(initialUserID))    {

                            Runnable run = new Runnable() {

                                @Override
                                public void run() {
                                    // TODO Auto-generated method stub


                                    ImageView postYourLike = (ImageView) findViewById(R.id.postYourLike);
                                    postYourLike.setBackgroundResource(R.drawable.btn_icon_liked);
                                }
                            };
                            TestNewsFeeds.this.runOnUiThread(run);
                        }
                    }

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
最佳回答

您可以使用此 fql。 替换后缀(_id)

SELECT likes.can_like, likes.user_likes FROM stream WHERE  post_id = "1274834235_3976149403543"

如果用户- 喜欢是真实的, 他喜欢这样 。

 {
  "data": [
    {
      "likes": {
        "can_like": true, 
        "user_likes": false
      }
    }
  ]
}
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签