Tags 使用Android Facebook sdk标记wallpost中的好友

Tags 使用Android Facebook sdk标记wallpost中的好友,tags,facebook-android-sdk,Tags,Facebook Android Sdk,我正在尝试使用android facebook sdk在墙报上标记一个朋友。然而,应该是标签的东西是空白的,什么都没有。这是我使用的代码: Bundle params = new Bundle(); access_token = fb.getAccessToken(); try { params.putString("format", "json"); par

我正在尝试使用android facebook sdk在墙报上标记一个朋友。然而,应该是标签的东西是空白的,什么都没有。这是我使用的代码:

            Bundle params = new Bundle();
            access_token = fb.getAccessToken();

            try {
                params.putString("format", "json");
                params.putString("access_token", access_token);
                String url = "https://graphs.facebook.com/me/friends";
                String response = Util.openUrl(url, "GET", params);
                JSONObject json = Util.parseJson(response);
                JSONArray array = json.optJSONArray("data");

                for(int i = 0; i < array.length(); i++) {
                    String tempName = array.getJSONObject(i).getString("name");
                    String tempID = array.getJSONObject(i).getString("id");

                    //Probably should have some if-tests here

                    if(tempName.contains(*nameOfFriend*)) {
                        Bundle bundle = new Bundle();
                        bundle.putString("message", "App tagging test");
                        //this is where the tagging is supposed to happen
                        bundle.putString("tags", *UserID*);
                        try {
                            fb.request("me/feed", bundle, "POST");
                            Toast.makeText(getApplicationContext(), "Tag-test", Toast.LENGTH_SHORT).show();
                        } catch (MalformedURLException e) {
                            Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        } catch (IOException e) {
                            Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }
                    } else {
                        Toast.makeText(getApplicationContext(), "Couldn't find friend", Toast.LENGTH_SHORT).show();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
Bundle参数=新Bundle();
access_token=fb.getAccessToken();
试一试{
putString(“格式”、“json”);
参数putString(“访问令牌”,访问令牌);
字符串url=”https://graphs.facebook.com/me/friends";
字符串响应=Util.openUrl(url,“GET”,参数);
JSONObject json=Util.parseJson(响应);
JSONArray数组=json.optJSONArray(“数据”);
对于(int i=0;i
我只授予了“发布流”的权限,是否需要其他权限?
提前谢谢你们的帮助,伙计们

我看不到代码中的
place
的任何值,但在通过API为帖子中的人添加标签时,这是必需的

:

标记[…]注意:如果不指定位置,则不能指定此字段


下面是标记朋友的工作代码 此外,您还必须向fb提交您在devlepoer facebook帐户中创建的项目的可标记好友api功能的审查。在您获得提交批准后,以下代码将标记您的好友

     Bundle params = new Bundle();
    params.putString(Facebook.TOKEN, facebook.getAccessToken());
    params.putString("method", "photos.upload");
    params.putString("caption", ShareTripActivity.tripNotes); // text to post

    if(ShareTripActivity.arr_facebookID.size()>0)
    {
        String tagFriendListId="";
        for(int i=0;i<ShareTripActivity.arr_facebookID.size();i++)
        {

            tagFriendListId = tagFriendListId+"{'tag_uid':'"+ShareTripActivity.arr_facebookID.get(i)+"'} ,";

        }
        tagFriendListId=tagFriendListId.substring(0, tagFriendListId.length()-1);
         params.putString("tags","["+tagFriendListId+"]");

    }
   AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
    mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);

在此arr_facebookID中,arraylist包含您要标记的朋友的facebook用户id

非常感谢您的快速回复!从应用程序标记位置时,使用位置的习惯是什么?我是否必须创建一个报到的地方(即创建一个地方并将其称为与应用程序本身相同的地方),或者我是否应该根据海拔高度和长度检索物理位置?还是我完全误解了?您是否有可用的代码示例?再次感谢您的回复!Plasma请为您的客户提供解决方案question@jyomin不幸的是,我从未找到解决办法。另外,我问题中的代码现在已经过时了,因为它是针对旧的facebook SDK的。好的,没问题,谢谢你的回复。谢谢!我现在不使用facebook或android,所以我无法验证这是否有效。但干得好,我会让它被接受的。
    public void onComplete(final String response, final Object state)
    {
        try
        {
            // process the response here: (executed in background thread)
            Log.d("Facebook-Example", "Response: " + response.toString());
            JSONObject json = Util.parseJson(response);
            final String src = json.getString("src");

            // then post the processed result back to the UI thread
            // if we do not do this, an runtime exception will be generated
            // e.g. "CalledFromWrongThreadException: Only the original
            // thread that created a view hierarchy can touch its views."

        }
        catch (JSONException e)
        {
            Log.w("Facebook-Example", "JSON Error in response");
        }
        catch (FacebookError e)
        {
            Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError e, Object state)
    {
        // TODO Auto-generated method stub

    }

    public Bitmap getInputType(Bitmap img)
    {
        // TODO Auto-generated method stub
        return img;
    }

    public int getInputType()
    {
        // TODO Auto-generated method stub
        return 0;
    }

    public void onIOException(IOException e, Object state)
    {
        // TODO Auto-generated method stub

    }

    public void onFileNotFoundException(FileNotFoundException e, Object state)
    {
        // TODO Auto-generated method stub

    }

    public void onMalformedURLException(MalformedURLException e, Object state)
    {
        // TODO Auto-generated method stub

    }
}