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");
Related
I am sending message to facebook wall my post contain an image and title and caption and description.I want to give different hyperlink for different item of my single post.I am successful in sending post on facebook wall.but not able to give multiple url hyperlink.My code is here
Bundle postParams = new Bundle();
postParams.putString(Facebook.TOKEN, facebook.getAccessToken());
postParams.putString("name", "LangGuage");
postParams.putString("href", "http://www.facebook.com");
postParams.putString("caption",msg);
postParams.putString("picture",url1);
postParams.putString("description","Powered by::Hunka Technology Pvt. Ltd.");
postParams.putString("link", "http://www.hunkatech.com");
My image and message and title all have the same link.how to give different url to all.
UPDATE: I also tried to do this but get this:{"error":{"message":"(#100) Missing message or attachment","type":"OAuthException","code":100}}
JSONObject attachment = new JSONObject();
attachment.put(Facebook.TOKEN, facebook.getAccessToken());
attachment.put("message", "hi ");
attachment.put("name", "LangGuage");
attachment.put("link", "http://www.facebook.com");
attachment.put("caption", msg);
JSONObject media = new JSONObject();
media.put("type", "image");
media.put("picture", url1);
media.put("link","http://www.google.com");
attachment.put("media", new JSONArray().put(media));
JSONObject properties = new JSONObject();
JSONObject prop1 = new JSONObject();
prop1.put("text", "Powered by::Hunka Technology Pvt. Ltd.");
prop1.put("link", "http://www.hunkatech.com");
properties.put("Get the App for free", prop1);
attachment.put("properties", properties);
Log.d("FACEBOOK", attachment.toString());
Bundle params = new Bundle();
params.putString("attachment", attachment.toString());
String res = facebook.request("me/feed", params, "POST");
System.out.println("----resp" + res);
Is it possible from any way..
First, the href field doesn't exist for a post, but this will simply be ignored.
You can't get what you want. A post can contain:
a message that allows as many links as you wish,
only one caption link (a caption has a title, description, image and url).
This sample code:
Bundle postParams = new Bundle();
postParams.putString(Facebook.TOKEN, facebook.getAccessToken());
/* Caption information (to highlight one link only) */
postParams.putString("caption", "Stack Overflow");
postParams.putString("picture", "http://myrrix.com/wp-content/uploads/2012/06/stackoverflow.png");
postParams.putString("description","A language-independent collaboratively edited question and answer site for programmers.");
postParams.putString("name", "stackoverflow.com"); //Name of the link
postParams.putString("link", "http://stackoverflow.com");
/* End of the caption information */
response = facebook.request("me/feed", postParams, "POST");
... results to:
The division you can see on the image above is in fact one link, a link which is specified by the link field. All the other fields only are textual and pictural information. In HTML it would be:
<div id="caption"> ... </div>
Now, I know that it's common question, but since "message" parameter is not valid, I wonder how to post just message to my facebook wall?
I use this:
public void postOnWall(Facebook mFacebook) {
try{
Bundle parameters = new Bundle();
parameters.putString("caption", "Caption");
parameters.putString("description", "Description");
mFacebook.dialog(this, "feed", params, new PostDialogListener());
}
catch(Exception e){}
}
I always get empty form without any title or content. I tried all params from facebook sdk docs but still no results.
UPD: when I say empty I mean this:
Why is the message parameter invalid? If you want to only post a message on your wall its should simply be just a matter of doing the following:
Bundle params = new Bundle();
params.putString("message", "test message on my wall");
mAsyncRunner.request("feed", params, "POST", new PostDialogListener(), null);
Please see below link of Stack overflow's answer for how to integrate facebook into your android application and if u have any query regarding that then tell me.
Post status on Facebook
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){}
I am using Faccebook android API (com.facebook.android) to post the messages on facebook.
Facebook mFacebook = new Facebook(Constants.APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
Bundle parameters = new Bundle();
parameters.putString("message", "this is a test post");// the message to post to the wall
mFacebook.dialog(this, "stream.publish", parameters, new SampleDialogListener());
Everything is working fine. I'm able to login and post the message, but after login, it is displaying a intermediate dialog, "Publish story" with a text box with my post msg, "this is a test post" that is editable by the user, but i want to post the messages immediately after login without having this intermediate post screen.
Can anybody help me how to achieve this.
Thanks,
nehatha
This is how you do it:
Bundle bundle = new Bundle(3);
bundle.putString("message", "Hello!");
mFacebook.request("me/feed", bundle, "POST");
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.