how to to disable facebook feed dialog - android

I had used a facebook app to post message on wall from https://github.com/facebook/facebook-android-sdk.
Here after user allows the app to use his/her profile, dialog feed comes with an editable area to publish or skip. I want a predefined message there but user will not be able to modify it. I am able to send the predifined message but its editable. How to make it uneditable.
Does any one knows how to do it??

You can just use a function to post directly to the users wall. Just make sure that it is clear to the user that the button posts directly, perhaps use a dialog to get them to confirm they want to post. Here is the code I use:
/**
* Post to a friends wall
* #param msg Message to post
* #param userId Id for friend to post to or null to post to users wall
*/
public void postToWall(String msg, String userID) {
Log.d("Tests", "Testing graph API wall post");
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle parameters = new Bundle();
parameters.putString("message", msg);
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", parameters, "POST");
Log.d(TAG,response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
} catch(Exception e) {
e.printStackTrace();
}
}

The dialog contains a WebView that loads the actual content from a Facebook URL. So to modify the editable area, you would need to modify the DOM of this webpage. See this question for more information about doing that. It is unclear to me from the answers in that question if this is possible. If it is, you'll need to add the code to the FbDialog class in the Facebook Android SDK.

Related

Facebook Open Graph - Custom link for image - Android

My application is very image centric and would like to allow the user to share images generated by the application on facebook posts. I am of the understanding that "User Generated" can only be used with user/camera taken photos so that is not an option. Correct?
Since I can't specify user generated, I'd like to either:
Set the link on the feed image such that the image in the album is opened, not the default og:url.
This link is by default the og:url specified in the open graph object.
I still need all of the other og:url links in the post except the image to point to the website page.
-OR-
Put an href link in the description (or somewhere else in the feed post) that opens the image in the album.
Unless I am mistaken, It doesn't seem that HTML href tags are allowed in posts/stories. Is there a way to do this in the caption of a custom story?
I am able to upload the image to the app's album and obtain the URL to the image in the album (also using "no story" so that it doesn't create a post).
Is what I'm trying to do possible?
How do I garner more control over the links set in a facebook feed post?
EDIT:
Regarding "User Generated" from facebook docs:
"The User Generated Photos action capability can only be used if the photos are original and taken by a user with an actual camera."
I don't want to generate two stories. Ideally I want ONE story that features an image that can be clicked on that links to the original full size image in the app album. The rest of the story shares some details about the image (desc. etc.). So I guess, in a way, I'm looking for a workaround for the camera/photo requirement.
I don't mind the standard story layout (with a smaller image with title, description/captions) but just want to link that image to one in the users application album.
EDIT:
I'm realizing that an Open Graph Story isn't the way to go here. I have instead gone to simply using the Graph API. (https://developers.facebook.com/docs/graph-api/reference/user/photos/) This allows me to post a link in the user comments along with a photo. For anyone interested:
public static void doImagePost(final Bitmap _sideBySide, String _comments) {
Bundle parameters = new Bundle();
parameters.putParcelable("image", _sideBySide);
String message;
if(_comments != null)
{
if(!_comments.isEmpty())
{
message = _comments + '\n' + '\n' + JSBridge.getURL();
} else {
message = JSBridge.getURL();
}
} else {
message = JSBridge.getURL();
}
//Plain Http://blahblahblah.com/foobar/whatever gets turned into a link in the message field
parameters.putString("message", message);
Bitmap redSideBySide = EHelper.reduceImageSize(_sideBySide, (int)4E6);
Session session = Session.getActiveSession();
if(session == null) {
requestPublish(MODE_PHOTO, redSideBySide, _comments);
return;
} else {
if(!session.isOpened())
{
requestPublish(MODE_PHOTO, redSideBySide, _comments);
return;
}
}
//Here is the Graph API request.
Request imagePostRequest = new Request(Session.getActiveSession(), "me/photos" , parameters, HttpMethod.POST, new Request.Callback() {
#Override
public void onCompleted(Response response) {
if(response.getError() == null)
{
Toast.makeText(m_Context, "Post image success", Toast.LENGTH_SHORT).show();
//m_Images = null;
dismissProgressDlg();
} else {
Toast.makeText(m_Context, "Error posting image to facebook: " + response.getError().getErrorMessage(), Toast.LENGTH_SHORT).show();
Log.e(DEBUG_TAG, "Error posting image to facebook: " + response.getError().getErrorMessage());
dismissProgressDlg();
}
}
});
showProgressDialog("Posting to Facebook...");
imagePostRequest.executeAsync();
}

Android: Facebook 3.0 Post on friends wall using the FQL request response (As of Apr23,2013)

My app generates custom listview of friends arrange by their birthday. So I have used SELECT name, uid, pic_square, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by birthday_date.
Now when the user click a friend(from the listview) it will prompt the user if s/he want to post to that friends wall. I know how to do it the old way, but I'm getting confuse because of How to send a post to Facebook friend's wall android SDK 3.0 .
In that question:
The Facebook SDK for Android provides a method to let you publish
stories from your app to a user's timeline. You can also use this
method to post a status update on your user's behalf. This method uses
the Graph API, and is an alternative to using the Feed Dialog
http://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/
also:
never use Graph-API for posting on friend's wall. because it is disabled after 6, Feb 2013. FB recommend u to use Feed Dialog for posting on friend's or your own wall. this is the link for how to use Feed Dialog : http://developers.facebook.com/docs/howtos/androidsdk/3.0/feed-dialog
I have seen both links, but both only show how to post on your own wall. Can anyone give me
a good latest example or at least, point me to the right direction on how to post to your friends wall using the FQL request response via Facebook Android SDK 3.x (As of the moment the version is 3.0.2b)?
I have found the solution. You only need to add the "to" and "from" parameters. Below is my sample:
For wall posting to a single friend:
private void publishFeedDialog(String friend_uid) {
Session session = Session.getActiveSession();
if (!hasPublishPermission()) {
// We don't have the permission to post yet.
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, WRITE_PERMISSION));
}
if (user != null && friend_uid != null && hasPublishPermission()) {
final Activity activity = this;
Bundle params = new Bundle();
//This is what you need to post to a friend's wall
params.putString("from", "" + user.getId());
params.putString("to", friend_uid);
//up to this
params.putString("name", "Facebook SDK for Android");
params.putString("caption", "Build great social apps and get more installs.");
params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
#Override
public void onComplete(Bundle values, FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(activity,
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(activity,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(activity,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(activity,
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}
}).build();
feedDialog.show();
}
}
For wall posting to many friends:
RequestsDialogBuilder instead of FeedDialogBuilder because the second one only allows multiple ids on the parameter "to", while the first one can receive many (not sure about the limit though, but I think is about 50)
credits to: gian1200
Possible duplicate... I think you should check the Demo FB provided
Facebook - Post to wall from Android application
UPDATED:
Well there is this.
http://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/
Facebook actually recommends using the Feed. Check it out

post NOT predifined messages on facebook wall from android application

I'm trying to create an android application which would allow the users to post messages on their facebook wall and also on their friends wall.
I've been through a few tutorials but in each of them is done barely the same thing:integrate facebook in application, the login authorization and posting a predifined message on the walll.
I'm using facebook sdk and I wonder is possible for the user to write directly to his wall in a dialog window???
What kind of authorization I need and if u could give me an example would be great.Thank u!
Take a look at this tutorial here and there is part 2 here. It will guide you though setting up the application to use facebook. Once you have all that setup you can use a function like this to post a msg to someones wall:
/**
* Post to a friends wall
* #param msg Message to post
* #param userId Id for friend to post to or null to post to users wall
*/
public void postToWall(String msg, String userID) {
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle parameters = new Bundle();
parameters.putString("message", msg);
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", parameters, "POST");
Log.d(TAG,response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
} catch(Exception e) {
e.printStackTrace();
}
}

send an invitation to facebook friends to join my website

I have build an android application in which I've integrated faceboook using the facebook-sdk package.I've also succeded to retrieve in my application the name of all my facebook friends, their names and their id's.Further I want to send from my application an invitation to all facebook friends to join a website.Can u point me in the right direction cause I haven't found anything on the internet.Thank you
Try using the code below, if you follow the tutorials i gave you in your other question it will work no probs!
protected void postOfferToWall(String userID){
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle params = new Bundle();
params.putString("message", "message goes here");
params.putString("link", "http://mysite.com");
params.putString("caption", "Click the link");
params.putString("description", "description of link");
params.putString("name", "name of link");
params.putString("picture", "http://url.to.my.picture/pic.jpg");
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");
Log.d("Tests",response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
}catch(Exception e){
e.printStackTrace();
}
}
For a quick reference using the Graph API to post to your friends wall, see Graph API - Facebook Developers. There is a subsection called Publishing, where they use curl to post to a friends wall. Of course you need to get the access tokens and permissions to do such activities but it is all explained here.

Creating a custom Wall Post with Facebook API on Android

I'm new to Facebook API on Android, and basically, what I'm trying to do is creating custom wall post for an application I'm developing.
Like when you listen a Shazam a song and you can share the result with your friends.
I believe I've got to create a custom attachment. Here's my code for setting the attachment:
mPostButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Bundle myParams = new Bundle();
String attachment="{\"name\":\"Gran Turismo 5\"," +
"\"href\":\"http://www.unknown.com/?lang=fr\"," +
"\"caption\":\"Sony Computer Entertainment\",\"description\":" +
"\"Une vidéo proposée par Cedemo.\",\"media\":" +
"[{\"type\":\"image\",\"src\":" +
"\"http://www.unknown.com/prepicture//thumb_title/15/15061_1.jpg\"," +
"\"href\":\"http://www.unknown.com/?lang=fr\"}],\"properties\":" +
"{\"Autre lien\":{\"text\":\"Cedemo\",\"href\":\"http://www.unknown.com\"}}}";
myParams.putString("attachment", URLEncoder.encode(attachment);
mFacebook.dialog(Option.this, "stream.publish",myParams,
new SampleDialogListener());
And then, later on:
public class SampleDialogListener extends BaseDialogListener {
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
mAsyncRunner.request(postId,values, new WallPostRequestListener());
} else {
Log.d("Facebook-Example", "No wall post made");
}
}
}
I didn't wrote the attachment String, It's just a test taken from another question made in this forum. Anyway, when I call myAsync.request, my app shows an error message, how am I supposed to pass the attachment to my dialog?
Hope I've been clear enough.
Are you sure you need to set custom parameters? It sounds like you can just want to post a Facebook message directly to the wall: you can do this by simply handing in the message parameter as a string -- you only need all that JSON if you want to attach an image etc. And note on facebook's page it says using this api call won't post a status update that others can see on their feed, it will just appear on their own wall. If you just want to post a message with a link you should just be able to use your mAsyncRunner (once you have your valid Facebook session) using this:
String message = "Post this to my wall";
Bundle parameters = new Bundle();
parameters.putString("message", message);
mAsyncRunner.request("me/feed", parameters, "POST", new WallPostRequestListener());
Also may help if you posted the error/response code you're getting from Facebook.

Categories

Resources