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.
Related
I know this question has been asked so many times.
In my app I also want to integrate Facebook like button,after doing lots of R&D I came across the below link
https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes
and I am using the below code in my app,
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
but when I click the like button nothing is happening.
Could you all please guide me how to use the above code.
One more thing an extra permission is needed for implementing the above code "Permission: publish_actions".How to get this permission?
First open session with publish permission using this
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.
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
I'm using FB API 3.0 for Android, and according to examples for Session I use
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image, new Request.Callback();
to upload the image.
I need to add some default text to this image, but I can't figure out where to put it.
In old API there was a bundle of parameters that were sent:
params.putByteArray("picture", imgData);
params.putString(Facebook.TOKEN, accessToken);
params.putString("caption", MyGlobals.INSTANCE.activeSetting.f_name);
What is the proper way to add text to Request for newUploadPhotoRequest?
tnx.
After you create the request and before you execute it, you can do the following:
// Get the current parameters for the request
Bundle params = request.getParameters();
// Add the parameters you want, the caption in this case
params.putString("name", "My Caption String");
// Update the request parameters
request.setParameters(params);
// Execute the request
Request.executeBatchAsync(request);
With the above solution we are unable to add description to image.
Solution:
replace name with message Because:
params.putString("name", "My Caption String");
putString first parameter is key for My caption String that key is unique one that unique was taken as message.
I have been searching for this all day and just when I find something, I find it is not what I am looking for. In short, I am upgrading my app to use the Facebook graph API for Android and the documentation is horrible. All I want is to upload a picture into the default album for the app. I have the following code:
Facebook f = new Facebook(APP_ID);
Bundle parameters = new Bundle();
parameters.putString("message", caption);
parameters.putByteArray("picture", data);
f.dialog(mContext, "publish.stream", parameters, this); //TODO: This is wrong
I think the publish.stream is what is the problem because the exception that I got when I did my "this doesn't have a prayer" test was a malformedURLException.
Can someone tell me if I am even on the right track?
Thanks,
Jake