我只是想从我的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。
感谢。
答案 0 :(得分:0)
你去吧
protected void postOnWall(String friendID)
{
Bundle params = new Bundle();
params.putString("message","put your message here");
params.putString("caption", "put your caption here");
params.putString("description", "Put your description here");
params.putString("name", "put a name here");
params.putString("picture", "URL of picture");
params.putString("link", "If any link);
asyncRunner.request(((friendID == null) ? "me" : userId) + "/feed", params, "POST", new WallPostRequestListener(),null);
}