[英]Post a message on facebook friend's wall in through Android applcation
[英]post message on friend facebook wall in android
我只是想从我的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。
谢谢。
干得好
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.