I want to check in a place using Facebook sdk 3.And it should be post in wall as a check in .I have the place id .does any one have idea how to do it and any code >>
Bundle data = new Bundle();
data.putString("access_token", "YOUR ACCESS TOKEN");
data.putString("place", "your_place_id");
data.putString("message","Your Text here");
JSONObject coordinates = new JSONObject();
coordinates.put("latitude", "LATITUDE");
coordinates.put("longitude", "LONGITUDE");
data.putString("coordinates",coordinates.toString());
data.putString("tags", "user_id");
String response = faceBook.request("me/checkins", data, "POST");
Related
I could check in with the older Facebook SDK used this code:
Facebook fb = new Facebook("APP ID");
Bundle params = new Bundle();
params.putString("access_token", "TOKEN");
params.putString("place", "PLACE ID");
params.putString("message","SOMETHING MESSAGE");
JSONObject coordinates = new JSONObject();
coordinates.put("latitude", "LATITUDE");
coordinates.put("longitude", "LONGITUDE");
params.putString("coordinates",coordinates.toString());
params.putString("tags", "USER ID");
String response = fb.request("me/checkins", params, "POST");
But the fb = new Facebook() and the fb.request() functions are deprecated in new 3.0 Facebook SDK! What can I replace them with? How can I check in with using the 3.0 Facebook SDK?
The Graph API need "publish_checkins" extended permission in Facebook app, but this permission is deprecated also.
You should use the static methods of the Request class to create requests and execute them.
Looks like the most suitable method would be newStatusUpdateRequest that takes a GraphPlace as a parameter.
Alternatively, you can use the newPostRequest which allows you to construct a request that is much more similar to the way it was in previous SDK.
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>
I'm using the following snippet to request the friendslist of the authorized user:
System.out.println("AT: " + facebook.getAccessToken());
String response = facebook.request("me/friends?fields=first_name,last_name,id,gender");
The response I get:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
I'm printing the accesstoken, this gives me a valid token. Also, getAccessExpires() returns a time in the future. When I request the url "me/friends" without any params, I get the expected (but with less data) friends list without errors.
How can I solve this?
String response = facebook.request("me/friends?fields=first_name,last_name,id,gender");
That is the incorrect way to use facebook.request. I'm assuming you're not using the beta Android SDK so the correct way to do this is to do the following:
Facebook facebook = new Facebook(YOUR_APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
Bundle params = new Bundle();
params.put("fields", "first_name, last_name, id, gender");
mAsyncRunner.request("me/friends", params, new RequestListener() {
// get response here
....
});
Hope this helps.
I have facebook ids of some of my friends. I want to post on my newsfeed,by using facebook graph api.
How can I make only these friends(facebook ids I have) to see my post?
Did I need to create any group for this?
Yes, it is possible. In the parameter bundle, add a privacy field. see example below:
public String postToWall() {
Bundle params = new Bundle();
params.putString("message", "test message");
JSONObject privacy = new JSONObject();
privacy.put("value", "CUSTOM");
privacy.put("friends", "SOME_FRIENDS");
privacy.put("allow", "FRIEND_ID_1,FRIEND_ID_2...");
params.putString("privacy", privacy.toString());
Facebook facebook = new Facebook(YOUR_APP_ID);
AsyncFacebookRunner mAsyncFacebookRunner = new AsyncFacebookRunner(facebook);
mAsyncFacebookRunner.request("me/feed", params, "POST", new BaseRequestListener() {
...
});
A post by its definition can be seen by everybody.
Alternatively you can
Post to a pre-created group
Message a group of friends
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){}