2017-07-28 66 views
0

我想采取Facebook的张贴图像的Url。我成功地张贴在Facebook上照片与logInWithPublishPermissions但我想在回调后图像的链接或URL ....如何获得分享(张贴)照片URL或链接Facebook的SDK?

SharePhoto photo = new SharePhoto.Builder() 
      .setBitmap(bitmap) 
      .setCaption("VodaFone Rakshavandhan!") 
      .build(); 

    SharePhotoContent content = new SharePhotoContent.Builder() 
      .addPhoto(photo) 
      .build(); 



ShareDialog shareDialog = new ShareDialog(FacebookShareActivity.this); 
    shareDialog.show(content, ShareDialog.Mode.AUTOMATIC); 

    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { 
     @Override 
     public void onSuccess(Sharer.Result result) { 

      Log.e("@@@result", String.valueOf(result)); 

     /* "/"+mFBID+"_"+postid+"?fields=link,message",*/ 
      String postid=result.getPostId().toString(); 

     mUrlFb="https://www.facebook.com/photo.php?fbid="+postid; 
      Log.e("@@@mUrlFb",mUrlFb); 

       GraphRequest request = new GraphRequest(
         accessToken, 
        "/"+mFBID+"_"+postid, 
        null, 
        HttpMethod.GET, 
        new GraphRequest.Callback() { 
         public void onCompleted(GraphResponse response) { 


     Log.e("@@response", String.valueOf(response)); 

         } 



    }); 


      Bundle parameters = new Bundle(); 
      parameters.putString("fields", "id,link,message"); 
      request.setParameters(parameters); 
      request.executeAsync(); 
     /* new GraphRequest(
        AccessToken.getCurrentAccessToken(), 
        result.getPostId(), 
        null, 
        HttpMethod.GET, 
        new GraphRequest.Callback() { 
         public void onCompleted(GraphResponse response) { 
           Log.e("@@response", String.valueOf(response)); 
         } 
        } 
      ).executeAsync();*/ 




     } 

     @Override 
     public void onCancel() { 
     } 

     @Override 
     public void onError(FacebookException e) { 
      e.printStackTrace(); 
     } 
    }); 

我正在从这个图表请求的响应

{Response: responseCode: 200, graphObject: 
{"id":"104752556880730_105851436770842"}, error: null} 

任何帮助欣赏。

+1

你需要采取帖子ID,你的反应得到的,并且API请求使用作出这样的,请求'permalink_url'该帖子的字段。 – CBroe

+1

仔细阅读[this](https://developers.facebook.com/docs/graph-api/reference/photo)一小段,有一个名为“link”的字段 - Facebook上的照片链接 –

+0

@CBroe谢谢主席先生,这很好。我传递了请求中唯一的permalink_url,它会回复我,我再次感谢。 –

回答

0

特别感谢@CBroe

只添加参数**permalink_url**

parameters.putString("fields", "id,link,message,permalink_url"); 
相关问题