我只想从我的 android 应用程序向我朋友的 facebook 墙上发布一条短信。在这里我列出了我朋友的列表并获得了我需要发送给的特定朋友 ID。但我无法将消息发送给特定的朋友.以下是我的代码。
facebook = new Facebook("My App Id");
asyncRunner = new AsyncFacebookRunner(facebook);
FaceBook.facebook.authorize(this, new String[] { "user_status", "user_about_me", "email", "publish_stream", "read_stream", "offline_access" }, new DialogListener() {
@Override
public void onComplete(Bundle values) {
JSONObject jObject;
try {
jObject = new JSONObject(FaceBook.facebook.request("me"));
Bundle params = new Bundle();
params.putString("message", "My message");
params.putString("target_id","My friend fb Id here");
params.putString("method", "stream.publish");
//String response = authenticatedFacebook.request(params);
FaceBook.asyncRunner.request("me/feed", params, "POST",
new ProductUploadListener(), null);
Toast.makeText(getApplicationContext(), "Successfully post..", Toast.LENGTH_SHORT).show();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFacebookError(FacebookError error) {
Toast.makeText(fbFriendsList.this,
"Facebook onFacebookError", Toast.LENGTH_LONG).show();
}
@Override
public void onError(DialogError e) {
Toast.makeText(fbFriendsList.this, "Facebook onError",
Toast.LENGTH_LONG).show();
}
@Override
public void onCancel() {
}
});
}
public class ProductUploadListener extends BaseRequestListener {
public void onComplete(final String response, final Object state) {
}
}
我在哪里做错了。我也使用了 android facebook SDK。
谢谢。