facebook post image /文字使用图形api错误

问题描述:

需要发布状态消息,或者用户是否在facebook上使用该状态消息选择了一个图像而不使用对话框。facebook post image /文字使用图形api错误

final Session sessionfb = ParseFacebookUtils.getSession(); 

    List<String> permissions = sessionfb.getPermissions(); 
    if (!permissions.contains("publish_actions")) { 

     Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
       FlyTags.this, Arrays.asList("publish_actions")) 
       .setCallback(newPermissionsCallback).setRequestCode(1); 
      sessionfb.requestNewPublishPermissions(newPermissionsRequest); 

    } 
    else { 

     Bundle parameters = new Bundle(); 
     parameters.putString("message", mfinalmsg); 
     parameters.putString("description", "test"); 

     if (imgdata != null) { 

      parameters.putByteArray("picture", imgdata); 
         } 
     new Request(sessionfb, "me/photos/feed", parameters, HttpMethod.POST, 
       new Request.Callback() { 
        public void onCompleted(Response response) { 

         Debug.e("facebook post response", 
           response.toString()); 
        } 
       }).executeAsync(); 

响应:

{Response: responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: 100, errorType: FacebookApiException, errorMessage: Invalid parameter}, isFromCache:false} 

使用我/饲料如果状态包含。如果连接一个图像使用我/照片。你应该有一个发布许可文本。

String graphapimethod = "me/feed"; 
    Bundle parameters = new Bundle(); 
    parameters.putString("message", mfinalmsg); 
    parameters.putString("description", "testhashmash"); 

    if (imgdata != null) { 

     graphapimethod = "me/photos"; 
     parameters.putByteArray("picture", imgdata); 

    } 
    // "me/feed" 
    new Request(session, graphapimethod, parameters, HttpMethod.POST, 
      new Request.Callback() { 
       public void onCompleted(Response response) { 
        /* handle the result */ 

        if (response.getError() == null) { 
         Toast.makeText(FlyTags.this, "Posted succeffully.", 
           Toast.LENGTH_SHORT).show(); 
         dialog.dismiss(); 

        } 

        else { 

         Toast.makeText(FlyTags.this, 
           "oops..please try again", 
           Toast.LENGTH_SHORT).show(); 
        } 

        Debug.e("facebook post response", response.toString()); 
       } 
      }).executeAsync();