Facebook API 3.0. - Add bundle information to image upload - android

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.

Related

Android facebook graph api add place or location params with photo upload

How can I send the place params while uploading a photo from android to facebook.
Bundle params = new Bundle();
params.putByteArray("photo", byteArray);
params.putString("caption", "FbAPIs Sample App photo upload");
//params.putString("place", "Banglore");
//params.putString("location", "banglore");
Utility.mAsyncRunner.request("me/photos", params, "POST",
new PhotoUploadListener(), null);
Add the place to the params, much like you did the caption.
params.putString("place","someLocation");
You're almost there. Instead of using "Bangalore" for example, pass in the Facebook place ID.
Ex:
params.putString("place", "106377336067638");
For reference, see: https://developers.facebook.com/docs/reference/api/user/#photos

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

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.

how to pass my image to facebook feed dialog android

I am using following code to post on a user's wall.
Bundle params = new Bundle();
params.putString("message", facebookMessage);
params.putString("link", ComLabelConstants.FACEBOOK_LINK);
params.putString("name", linkname);
params.putString("picture", "http://some link");
params.putString("caption", ComLabelConstants.FACEBOOK_LINK_CAPTION);
params.putString("description", "This is description");
// displaying facebook dialogs
mFacebook.dialog(FbookAlertBoxActivity.this, "feed", params,new SampleDialogListener(this, mAsyncRunner));
Now, I want to use my own image in drawable folder to post on user's wall and not from any link. Can we do that? anyone have solution for this.
You can't publish an image directly to a feed like you are asking - you can only pass a link to the image.
The only solution is to upload the image to a web server and then pass the URL of the image as the picture parameter.

How to set an icon and add an action in a facebook post using facebook api?

I'm using facebook-android-sdk to post a message on facebook using the bundle shown below.
The message is displayed correctly, but the icon is not shown, and I can't find a way to get something like the image below.
Is this the correct way to set an icon?
How ca I add in the bundle something like "Get Spotify" as seen in the image?
Thanks.
Bundle params = new Bundle();
params.putString("message", "icon please");
params.putString("link", "http://www.digital-farm.org");
params.putString("name", "whip'em");
params.putString("description", "description");
params.putString("picture", "http://lib.store.yahoo.net/lib/yhst-17155638221985/img-twitter.gif"); //used for testing
params.putString("icon", "http://photos-c.ak.fbcdn.net/photos-ak-snc1/v27562/74/174829003346/app_2_174829003346_2760.gif"); //used for testing
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
mAsyncRunner.request("me/feed", params, "POST", new PostRequestListener(), null);
Actually that icon you show in your screen shot is probably the Facebook application's icon. It's set within the Facebook application's configuration/settings. When you post via your Facebook application, the icon should appear automagically. See screen shot below for example.
Assuming you're using the Facebook SDK for Android, when you instantiate your Facebook object, you pass your Facebook application's ID as parameter into the constructor. That's how the wall posting is associated with your Facebook application.

Categories

Resources