How to share on facebook using graph api in android - android

I want to share a link in my application.I didnt find any api for sharing link in graph api.
What is the difference between sharing and posting in facebook?How can I perform sharing ?
Thanks in advance

You can post to wall on facebook using this code:
Bundle parameters = new Bundle();
parameters.putString("message","YOUR_MESSAGE");
parameters.putString("link", "ANY_LINK");
String response = facebook.request("me/feed", parameters,
"POST");
Also to upload an image, you can use this code:
Bundle parameters = new Bundle();
parameters.putString("message","YOUR_MESSAGE");
parameters.putString("caption","ANY_CAPTION");
parameters.putByteArray("picture", "IMAGE_LINK");
String response = facebook.request("me/photos", parameters,
"POST");
Hope it will help you.

Related

Facebook SDK post with BOTH place AND picture

I'm using Facebook's latest SDK for Android.
Is it possible to post a status with BOTH place AND picture?
My bundle looks like this:
Bundle postParams = new Bundle();
postParams.putString("message", "Hi there!!");
postParams.putString("picture", "http://www.peleozen.net/pics/2_bus_face_logo.jpg");
postParams.putString("place", "204519339582365");
When I make the request, it results in a status with only the picture.
Making the request without a picture results in a checkin
So...is it possible to do both?
You can post to the /me/photos endpoint, so in a sense you're posting a photo, adding a location to it and the caption is the message. So as an example, if using the latest SDK, you could take a look at the HelloFacebookSample and make the following changes to the postPhoto method to try this out:
....
Bundle params = request.getParameters();
params.putString("message", "Hi there!!");
params.putString("place", "166793820034304");
request.setParameters(params);
Request.executeBatchAsync(request);
....
For reference, see: https://developers.facebook.com/docs/reference/api/user/#photos

Picture is not posted on facebook

hey I'm using this code technique to post on my fb wall
// parameters.putString("description", "Muslim Baby Names");
parameters.putString("picture","http://img208.imageshack.us/img208/4834/pic1qu.png");
it does make a post but picture odes not get posted.
Kindly tell me how should I do it
Check out our example app that uses the Android SDK, Hackbook. Here is the relevant code that uploads a photo to a user's wall from a remote URL.
For your example, this is how you would do it:
Bundle params = new Bundle();
params.putString("url", "http://img208.imageshack.us/img208/4834/pic1qu.png");
params.putString("caption", "Muslim Baby Names");
mAsyncRunner.request("me/photos", params, "POST");
Let me know if that helps!

Android Facebook SDK How To Update Notification

I am trying to update a notification via the Facebook ADK. The documentation says this:
"You can mark a notification as read by issuing an HTTP POST request to /NOTIFICATION_ID?unread=0 with the manage_notifications permission."
I know how to read the notifications with the graph path "me/notifications", but I am unsure of the code to do a POST to mark a notification as being read.
Facebook facebook = ......."Authorized Facebook Object"
Bundle parameters = new Bundle();
parameters.putString(Facebook.TOKEN, accessToken);
...
How do I add in the "/NOTIFICATION_ID?unread=0" parameters?
...
String result = facebook.request("me/notifications", parameters, "POST");
Thanks.
Ok...I figured this one out:
Facebook facebook = ...
String unreadParameter = "0";
Bundle parameters = new Bundle();
parameters.putString(Facebook.TOKEN, accessToken);
parameters.putString("unread", unreadParameter);
String result = facebook.request(notificationID, parameters, "POST");
The Graph Path needs to only be the "NOTIFICATION_ID" and nothing else...I was putting in "me/notifications/NOTIFICATION_ID" and other variations.
I hope that others find this helpful.

Android + Facebook API - write on Facebook wall with link to another Facebook page

I have a problem with Android Facebook API with writting to wall. I want to write there and add a link to another Facebook page. While other links work, Facebook links do not. Am I doing something wrong?
Normal links work:
// ...
Bundle parameters = new Bundle();
parameters.putString("message", "some message");
parameters.putString("link", "http://root.cz");
mFacebook.dialog(this, "stream.publish", parameters, new WallPostDialogListener());
// ...
Facebook links do not work:
// ...
Bundle parameters = new Bundle();
parameters.putString("message", "some message");
parameters.putString("link", "http://www.facebook.com/pages/Juky-MC/170228716347899");
mFacebook.dialog(this, "stream.publish", parameters, new WallPostDialogListener());
// ...
I get facebook window with "Sorry, something went wrong." "We're working on getting this fixed as soon as we can." error messages. Could anybody help me?
Thanks Jan
Have you tried removing the "www." at the "http://www.facebook.com/pages/Juky-MC/170228716347899" ?

Create photo album in facebook using android and Graph api

We have a problem creating photo album in facebook using android and graph API. We already have been able to upload photos to facebook using Graph API. We are using following for uploading a photo to facebook.
Bundle params = new Bundle();
params.putString("method", "photos.upload");
params.putString("title", uploadFile.getName());
params.putString("privacy", "{'value':'EVERYONE'}");
facebook.request("https://api.facebook.com/restserver.php?method=photos.upload",params,"POST");
Please let us know if anybody aware of. We have searched a
I have found the working solution for the above problem.
Bundle params = new Bundle();
params.putString("name", albumName);
String response = mFacebook.request("https://graph.facebook.com/me/albums",params,"POST");
String albumId=Util.parseJson(response).getString("id");
Above code will help create a new photo album with the albumName and return the album id generated by facebook.

Categories

Resources