I would like to post a picture to my friend's wall.
But I logged in to my account say test#gmail.com, but now I want to post on to any of my friend wall.
I am having all my friends id and Name.
Is it possible to Post a picture in friends wall by logged to my account? If so how is it possible?
try{
Bundle parameters = new Bundle();
JSONObject attachment = new JSONObject();
try {
attachment.put("message", "Messages");
attachment.put("name", "Get utellit to send messages like this!");
attachment.put("href", link);
} catch (JSONException e) {
}
parameters.putString("attachment", attachment.toString());
parameters.putString("message", "Text is lame. Listen up:");
parameters.putString("target_id", "XXXXX"); // target Id in which you need to Post
parameters.putString("method", "stream.publish");
String response = authenticatedFacebook.request(parameters);
Log.v("response", response);
}
catch(Exception e){}
The Facebook SDK in general, as well as the one for Android, allows you to do so. See the example code here.
Related
I'm using the facebook sdk to share on the facebook wall. If I'm using the admin account I'm able to share on facebook. Admin account means created app account. If I'm using an other facebook account I'm not able to share.
{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}
Below is the code snippet
private Facebook facebook = new Facebook(APP_ID);
private static final String[] PERMISSIONS = new String[] { "publish_actions" };
Bundle parameters = new Bundle();
parameters.putString("message", message);
parameters.putString("description", "topic share");
try {
facebook.request("me");
String response = facebook.request("me/feed", parameters, "POST");
Log.d(TAG, "got response: " + response);
} catch (Exception e) {
}
Can anyone help to fix this issue?
Thanks
Kamal
I tried many ways to post a message to friend wall but no success:
Post on user's friends facebook wall through android application
Post message to facebook wall from android fb sdk always error
I also tested my account id and friend id aren't block from facebook, they can post message together in browser.
Here is my try:
try {
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());
mAsyncRunner.request(((friendId == null) ? "me" : friendId) + "/feed", params, new WallPostRequestListener());
} catch (Exception e) {
e.printStackTrace();
}
But it response error:
{"error": {"message":"An access token is required to request this resource.",
"type":"OAuthException","code":104}}
Then I tried to add token to the parameter but not work
params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
The problem is I can login success without error.
So, I need the right way to post a message to friend wall that worked for me.
I am integrating Facebook in my app and I could do with ease,but I am facing a problem when I am trying to post a message with hyperlink on the wall, when I am trying to do this I am getting Missing message or attachment OauthException code 100, I was able to post a message without hyperlink. This is the code which I am using for posting on wall:
JSONObject attachment = new JSONObject();
attachment.put("message", "Messages");
attachment.put("name", "click");
attachment.put("href", "http://www.facebook.com");
Bundle parameters = new Bundle();
parameters.putString("attachment",attachment.toString());
response = mFacebook.request("me/feed", parameters,"POST");`
Can any one tell me where I am going wrong?
Thank you.
Try doing something like:
Bundle parameters = new Bundle();
parameters.putString("message", "Messages");
parameters.putString("name", "click");
parameters.putString("link", "http://www.facebook.com");
response = mFacebook.request("me/feed", parameters, "POST");
I'm able to post to a users wall using android application. but i have another request to post to a specific app page (which is created for the same app). But i couldn't find any resource regarding this...
can anyone help how to archive this...
So far to share on users wall this piece of code is working..
private void postOnFB(byte[] data) {
try {
Log.v("postImage", "in");
Bundle params = new Bundle();
params.putString("description", "Play this awesome bible game..");
params.putByteArray("picture", data);
params.putString("message", facebookPostingMessage
+ "\n http://www.momaco.lk/");
mAsyncFacebookRunner.request("me/photos", params, "POST",
new SampleUploadListener(), null);
} catch (Exception e) {
// Do nothing only to catch exception
e.printStackTrace();
}
}
Please can some one help me on this...
You can post to the app page's wall by issuing an HTTP POST request to the app page's feed connection:
http://graph.facebook.com/APP_PAGE_ID/feed
That is, you code should read
mAsyncFacebookRunner.request(APP_PAGE_ID + "/feed", params, "POST",
new SampleUploadListener(), null);
Note that its the app's page id you post to, not the app id.
I am developing an application which is able to let a user send a message to a friend on facebook. I have looked at Facebook API, Hackbook folder. I used the following code, but it did not work. It seems to ask me to implement a new dialog for it.
Bundle params = new Bundle();
params.putString("caption", app_name);
params.putString("picture", picture);
dialog(MyClass.this, "send", params, new UpdateStatusListener());
Any help is very appreciated !
Check this Snippet for Posting on Friend's wall :
try{
parameters.putString("message", "Text is lame. Listen up:");
parameters.putString("target_id", "XXXXX"); // target Id in which you need to Post
parameters.putString("method", "stream.publish");
String response = authenticatedFacebook.request(parameters);
Log.v("response", response);
}
catch(Exception e){}