问题
I'm trying to post a message on user's wall defined by it's ID, but in response I'm getting an error "Unknown method".
My code is:
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);
In LogCat i have:
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}
回答1:
Everything looks right except the graphPath
parameter in your Request
method. Instead of:
"/" + pickedUsersId.get(0) + "/feed"
do:
pickedUsersId.get(0) + "/feed"
There should not be a leading slash "/" in front of your graph path. You can always refer to our documentation to see how exactly to publish to feed. https://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/
来源:https://stackoverflow.com/questions/13290047/posting-on-facebook-wall-with-sdk-3-0