I am posting to a user's wall on Facebook. How can I add a link to the post next to the like and comment links, as seen on the illustration below. What is the parameter name I should include in my request?
This is what I eventually did:
The link besides the like and comment is called "actions". To add it, you need to create an array of actions (actually, as I understand only one action is supported). For example:
JSONObject actions = new JSONObject();
actions.put("name","Get Your App");
actions.put("link", "Your app URL");
parameters.putString("actions", actions.toString());
Here is list of all Post Fields.
link | The link attached to this post | Requires access_token | string containing the URL
Related
I want to post a tweet with image and text in my android app,but i want to # some other people at the same time,how should I do?
the twett result that I get just like ,that is from my publish # my friend.
my code:
StatusUpdate statu = new StatusUpdate("tweet text");
File tweetImg = getTwitterImagFile();
statu.setMedia(tweetImg);
mTwitter.updateStatus(statu);
You just need to add #[user_handle] to tweet text. If you are replying a tweet, you can set the parameter in_reply_to_status_id in the POST request.
See: https://dev.twitter.com/rest/reference/post/statuses/update
I have an application that show to the user articles from news feeds.
I want to add Facebook like mechanism, that when the user push the like button,
his Facebook account will show that he is like this article.
So, I downloaded the Facebook sdk, and worked with the open graph example.
The problem is that I can't find any good example of how to to this.
I understand that I have action types, and object types. I added action type of me/og.likes and now I need to send the url of the selected article.
What I do so far is:
I have this lines, what they do is only add which type of action my application can handle.
this is working fine.
Bundle params = new Bundle();
params.putString("object", "http://samples.ogp.me/226075010839791");
Request request = new Request(
Session.getActiveSession(),
"me/og.likes",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
Now I want to send the actual url of the selected article, do I need to use some kind of outside url of an object or I can build object in my application and send it?
Any help would be great,
thanks.
When creating an action you must be sure that facebook robot can see the URL and correct meta tags. You can debug your page on this page. So in your case as I understand facebook can't visit your application and therefore can't determine meta tags in your app. So the solution I can offer is creating a web page which will generate meta tags depending on the $_GET[] parameter. You can pass an article ID and generate meta tags for that ID.
There is library which completely solve this issue (project page):
dependencies {
compile 'com.shamanland:facebook-like-button:0.1.8'
}
The simplest way to add like button:
<com.shamanland.facebook.likebutton.FacebookLikeButton
style="#style/Widget.FacebookLikeButton"
app:pageUrl="http://url.to.like/page.html"
app:pageTitle="Title of page"
app:pageText="Short description of page"
app:pagePictureUrl="http://url.to.like/picture.jpg"
/>
This view will be drawn in your layout:
After clicking on it you will see the dialog with official Facebook 'Like' plugin.
Read more details.
I want to share multiple images along with the tweet on the Twitter, but i am not able to do so. I am able to tweet single photo along with the message but not getting to append other photos in the same tweet since twitter does not allow to tweet the same message for 8-10 hours or even a day. Here is my code, what i have done to tweet the message along the photo. Can anyone please let me know where i am lacking in the code or any better way to implement the requirement.
Here is the code for tweeting:
AccessToken accessToken = new AccessToken(access_token,
access_token_secret);
Twitter twitter = new TwitterFactory(builder.build())
.getInstance(accessToken);
File f = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath().toString()
+ "/xyz.png");
StatusUpdate statusUpdate = new StatusUpdate(status);
statusUpdate.setMedia(f);
twitter.updateStatus(statusUpdate);
Thanks in advance
After doing lot of R & D, i came to know that we can not post more than one image in a single tweet, and also Twitter does not allow same message to be twitted in short span of time. You can post it after several hours(may be around 7-8 hours), since it gives "Duplicate message error". So i called the function which helped posting tweet with the media file by taking one counter variable and checking with the list of images i had. So at the end i was able to post three different tweets as there were three images in my list.
And ya, you can check in this link in which you will come to know the number of images you can post in a single tweet
I want to post a pre-defined message on Facebook through my android application. I got everything to work except the 'properties' field. I want to post a message where it says:
More information: here
and when the user clicks on 'here', it should link to the page.
This is what I did:
Bundle params = new Bundle();
String s2 = "{'More information':{'text':'here', 'href':" + details + "}}";
params.putString("properties", s2);
where 'details' is the link to the page.
But it seems like facebook is not picking up this line. I successfully set up the caption, picture and other fields.
Any insights? Thanks!
This is by design, as far as I know, we do not support HTML in status updates. We will automatically create a link if you post a valid URL however, so I would suggest just pasting out the full link
".....More information: (www.yourURLhere.com)"
On Facebook, www.yourURLhere.com will be a clickable link.
I was playing with facebook android sdk. Till yesterday their sample Hackbook example code was working. But today it is not working any more. I looked into the json response and it seems like facebook changed their json response format.
This is the response for request field of "name, picture":
{"name":"Mohammad Haque","id":"xxxxxxxx","picture":{"data":
{"url":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-ash3\/xxxx.jpg","is_silhouette":false}}}
It looks like profile url now wrapped inside another parent item. Has anyone faced this problem? I could not find any relevant information on facebook.
Thanks
It is the Facebook updates http://developers.facebook.com/roadmap/
According to Facebook documentation (https://developers.facebook.com/docs/reference/api/user/) - picture returns string; If the "October 2012 Breaking Changes" migration setting is enabled for your app, this field will be an object with the url and is_silhouette fields; is_silhouette is true if the user has not uploaded a profile picture
I retrieved picture url by this query:
https://graph.facebook.com/me/picture?type=large
JSONObject jb=Util.parseJson(query);
JSONArray ja=jb.optJSONArray("picture")
JSONArray v=ja.optJSONArray("data")
JSONObject j=v.optJSONObject(0);
j.get("name").toString();
j.get("url").toString();
Just parse the JSON appropiately with the changes and it should work.