使用sdk 3.0在Facebook墙上发布

Zak*_*man 3 android facebook facebook-wall

我试图在用户的墙上发布一条消息,由它的ID定义,但作为回应我收到错误"未知方法".

我的代码是:

final Bundle params = new Bundle();

params.putByteArray("message", "Test".getBytes());
params.putByteArray("name", "American Virgin".getBytes());
params.putByteArray("link", "http://bit.ly/12345".getBytes());
params.putByteArray("description", "A Freshman College Girl on a scholarship from an ...".getBytes());
params.putByteArray("picture", "http://xxx/MOV1026.jpg".getBytes());

final Request postToWall = Request.newRestRequest(Session.getActiveSession(), 
                                                    "/" + pickedUsersId.get(0) + "/feed", params, HttpMethod.POST);
postToWall.setCallback( new Request.Callback() 
{

    @Override
    public void onCompleted(Response response) 
    {
        Log.i(Utils.LOG, response.toString());

    }
});
Request.executeBatchAsync(postToWall);
Run Code Online (Sandbox Code Playgroud)

在LogCat我有:

11-08 17:34:29.136: I/LOG(21699): {Response:  responseCode: 200, graphObject: null, error: {FacebookServiceErrorException: httpResponseCode: 200, facebookErrorCode: 3, facebookErrorType: null, message: Unknown method}, isFromCache:false}
Run Code Online (Sandbox Code Playgroud)

Jes*_*hen 5

除了方法中的graphPath参数外,一切看起来都是正确的Request.代替:

"/" + pickedUsersId.get(0) + "/feed"

做:

pickedUsersId.get(0) + "/feed"

在图形路径前面不应该有一个前导斜杠"/".您始终可以参考我们的文档,了解如何准确发布Feed. https://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/