How do I share Facebook contents on Android - android

I'm trying to share a post on my FB wall by an Android native app.
I'm following the official guide available # FBOfficial
I would know if it's possible to share a text, an image and an hashtag and also tag place or friends in the same post.
I tried to use the ShareContent class with no results.
If I use
new SharePhotoContent.Builder()...
it's not possible to add text, because the method "setQuote" is not available.
Otherwise, if I use
new ShareLinkContent.Builder()
it's not possible to add a picture.
I would also know why
setShareHashtag(new ShareHashtag.Builder())
works perfectly but
setPlaceId(String placeId)
never works, also if I add a valid placeId taken from PlaceIds
Is there a way to solve my problem?
TY in advance

Related

Url link breaking up in text message Android Application

i have a url link am trying to send to my user, but the link breaks up cause. it sends the full link but about half of it is not underlined as a link. this is what am trying to send
String locateUrl="http://maps.google.com?q="+latitude()+","+longitude();
first it does not recognize this ?q= as a link and it just breaks up from there, have checked other answers and tried them but seems not to be working
Just solved this by putting "/" before ?q= thereby making sure the link doesn't break
full link will then be
String locateUrl="http://maps.google.com/?q="+latitude()+","+longitude();
Your link may be breaking because of space at the beginning or in between trim it and then use it.
String locateUrl="http://maps.google.com?q="+latitude()+","+longitude();
locateUrl = locateUrl.trim();

Get Larger Image From Facebook Post?

I'm currently getting the newsfeed of a Facebook user. Currently, I can only retrieve thumbnail images that are associated with links, rather than the full-size image. Does anyone know how to get a larger image?
I've looked at the following posts and tried their solutions; however, the posts seem outdated and the facebook graph api seems to have changed since then:
Facebook Graph API Change: Picture type (size) no longer working?
Facebook API post: How to get larger thumbnail?
Please note that I'm on the me/home edge, so the answer below returns an error. See comments below.
my code is:
params.putString("fields","id,actions,application,caption,created_time,description,from,link,message,message_tags,"
+ "name,object_id,picture,place,source,status_type,story,updated_time,type,status_type,story,to,type,"
+ "updated_time,with_tags");
Change to this:
params.putString("fields","id,actions,application,caption,created_time,description,from,link,message,message_tags,"
+ "name,object_id,full_picture,place,source,status_type,story,updated_time,type,status_type,story,to,type,"
+ "updated_time,with_tags");
Here picture.height(1000) will give you a large image. and you can put your own required size but it is not supported in me/home i have searched a lot.
For Testing purposre use this link :Facebook graph explorer.
Eventually I came to this solution:
1) find the URL of the larger image (see code below)
2) get bitmap from URL and add to application UI.
The code mentioned above:
private String getRealURL(String smallURL){
if (smallURL.contains("url=http")){
String[] pieces = smallURL.split("url=");
pieces[1].replace("%2F", "//");
pieces[1].replace("%3A", ":");
Log.e("RealURL1:", pieces[1]);
return pieces[1];
}
else{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.setLength(0);
stringBuilder.append("https://graph.facebook.com/");
stringBuilder.append(item.getObjectID());
stringBuilder.append("/picture?type=normal&access_token=");
stringBuilder.append(Session.getActiveSession().getAccessToken());
Log.e("RealURL2:", stringBuilder.toString());
return stringBuilder.toString();
}
}
Simply use this field ?field=full_picture instead of picture.
?field=full_picture is the only way to get it to work now. I have been searching everywhere, and finally found the answer here. picture field doesn't support subfields any more so you can't use picture.width.height any more

How to like a website from my Android application

I have an application that show to the user articles from news feeds.
I want to add Facebook like mechanism, that when the user push the like button,
his Facebook account will show that he is like this article.
So, I downloaded the Facebook sdk, and worked with the open graph example.
The problem is that I can't find any good example of how to to this.
I understand that I have action types, and object types. I added action type of me/og.likes and now I need to send the url of the selected article.
What I do so far is:
I have this lines, what they do is only add which type of action my application can handle.
this is working fine.
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
Now I want to send the actual url of the selected article, do I need to use some kind of outside url of an object or I can build object in my application and send it?
Any help would be great,
thanks.
When creating an action you must be sure that facebook robot can see the URL and correct meta tags. You can debug your page on this page. So in your case as I understand facebook can't visit your application and therefore can't determine meta tags in your app. So the solution I can offer is creating a web page which will generate meta tags depending on the $_GET[] parameter. You can pass an article ID and generate meta tags for that ID.
There is library which completely solve this issue (project page):
dependencies {
compile 'com.shamanland:facebook-like-button:0.1.8'
}
The simplest way to add like button:
<com.shamanland.facebook.likebutton.FacebookLikeButton
style="#style/Widget.FacebookLikeButton"
app:pageUrl="http://url.to.like/page.html"
app:pageTitle="Title of page"
app:pageText="Short description of page"
app:pagePictureUrl="http://url.to.like/picture.jpg"
/>
This view will be drawn in your layout:
After clicking on it you will see the dialog with official Facebook 'Like' plugin.
Read more details.

construct predefined messages with properties to post on Facebook android

I want to post a pre-defined message on Facebook through my android application. I got everything to work except the 'properties' field. I want to post a message where it says:
More information: here
and when the user clicks on 'here', it should link to the page.
This is what I did:
Bundle params = new Bundle();
String s2 = "{'More information':{'text':'here', 'href':" + details + "}}";
params.putString("properties", s2);
where 'details' is the link to the page.
But it seems like facebook is not picking up this line. I successfully set up the caption, picture and other fields.
Any insights? Thanks!
This is by design, as far as I know, we do not support HTML in status updates. We will automatically create a link if you post a valid URL however, so I would suggest just pasting out the full link
".....More information: (www.yourURLhere.com)"
On Facebook, www.yourURLhere.com will be a clickable link.

Facebook "feed" dialog Display Issue

I am Trying to post on facebook with the help of "feed" dialog. I supply some information in post like "link","picture","caption","description","title" etc.
But when i share the post the preview look like the image below:
My Concern is this I want to show description right align to the dialog after the Image ends. Can i do this by some change in my code.
The updated Screen looks something Like the Image Below:
mFacebook.dialog(MyActivity.this, "feed",parameters, new FbDialogListener());
Where parameter is the object of Bundle contains all the values to be posted on Facebook.
There is the same issue with Iphone SDK too.
You can't do this, the dialogs are rendered from Facebook's side, as is the content itself once posted. You also appear to have attempted to embed HTML in the description, this will also not work as Facebook will not render client-supplied HTML in their interface.
Do not use Facebook's dialog, you can create your own views (e.g. UIView in iOS or View in Android) similar to the second dialog (or whatever you like). On share button tap you can use Facebook's graph API to share it on your wall.
iOS example
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[appDelegate.facebook accessToken],#"access_token",
<your FB app id>, #"api_key",
<message you want to post>, #"message",
imageData, #"source",
nil];
[appDelegate.facebook requestWithGraphPath:#"me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:appDelegate];
See here for graph API.
I am using a similar approach in my iOS app. I designed the share dialog almost similar to Facebook's share UI.

Categories

Resources