2017-01-04 16 views
0

以下はFacebookを利用して画像を共有するために私のコードです:Facebookの要求ではない応答

public static void fbShareImage(String photoPath) { 
     BitmapFactory.Options options = new BitmapFactory.Options(); 
     options.inPreferredConfig = Bitmap.Config.ARGB_8888; 
     Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options); 

     Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), bitmap, new Request.Callback() { 

      @Override 
      public void onCompleted(Response response) { 
       // TODO Auto-generated method stub 
       Log.e("Share", "upload success"); 
      } 
     }); 
     Request.executeBatchAsync(request); 
    } 

が、私はFacebookを利用して画像を共有したいです。リクエスト機能を使って共有しています。しかし、要求を実行すると、私は何の応答も受けていません。どんな助けでも貴重です。

+0

あなたは[リンク]をチェックしている(https://developers.facebook.com/docs/sharing/android):

だから、あなたは以下のコードを試すことができますか? –

+0

私はv4.xを使用していません。だからこのリンクは私には適していません –

答えて

0

共有ダイアログで参照しようとしている画像のURLを取得するには、リソースのIDで別のリクエストを行う必要があります。

Callback callback = new Callback() { 

    @Override  
    public void onCompleted(Response response) { 

    if (response.getGraphObject() != null) { 
     String imageUrl = (String) response.getGraphObject().getProperty("picture"); 
     // call to your sharing method 
    share(session, text, imageUrl);        
     } 
    } 
}; 


Request request = new Request(Session.getActiveSession(), imageid, null, HttpMethod.GET,  callback); 
request.executeAsync(); 
+0

は機能しません。私はonCompletedのログを追加します。それは呼ばれていない。 –

+0

共有に「ShareContentLink」を使用していないのはなぜですか?あなたのコードで何が起きているのか、モードの詳細を理解するのは本当に難しいですか? – Mrinmoy

+0

それ以外の場合は、このリンクを確認してください。助けてくれるといいですね。http://stackoverflow.com/a/20968646/5722385 – Mrinmoy

関連する問題