I created an app that gets the news feed from Facebook and displays it. I want to enable users to comment and like from within my app, but I couldn't find any API for that. I did find a custom URL scheme for Facebook: fb://post/{postId} which I'm trying to use. For each post, I get the post Id and create a link in a textview on Android pointing to that URL. I printed out the URL and this is an example: fb://post/47526370263_10152072729085264
likes is a TextView in my Facebook adapter with the text being the number of likes a post got. I want this view to contain a link to Facebook's app which will open that specific post.
String linkToPost = "fb://post/" + status.getId();
likes.setText(Html.fromHtml("" + status.getLikeCount() + " like"));
When I click on the link in my app nothing gets opened. How do I enable people to view/post comments/likes from within my Facebook News Feed app?
I saw a related answer after I posted this. The solution is to do:
likes.setMovementMethod(LinkMovementMethod.getInstance());
Related
I have searched SO and the web for a similar issue, and while others appear to have encountered this problem, their solutions are not working for me.
DFL parameter in Firebase Dynamic Links Builder
Starting with Android, I'm attempting to implement the Dynamic Links for my app. The app requires additional parameters on the dynamic link, so I'm manually constructing the link based on the information here: https://firebase.google.com/docs/dynamic-links/create-manually.
I have created my link in the following manner (code abbreviated for purposes of this post)
Uri.Builder builder = new Uri.Builder()
.scheme("https")
.authority(AppPrivate.Invitation.APP_CODE + ".app.goo.gl")
.path("/")
.appendQueryParameter("link", link)
.appendQueryParameter("apn", AppPrivate.PACKAGE)
.appendQueryParameter("dfl", desktopLink);
For my use case the link and desktopLink parameters are the same - they are actual working URLs on my website. Regardless of what device the user hits with the dynamic link, it should perform the desired action. Again, for purposes of simply getting this working, I've linked to our primary website (https://www.mytravelerapp.com).
When I send the invitation from my Android device, I generate an intent based on the code sample here: https://github.com/firebase/quickstart-android/blob/master/invites/app/src/main/java/com/google/firebase/quickstart/invites/MainActivity.java
return new AppInviteInvitation.IntentBuilder(context.getString(R.string.content_trip_invitation_title))
.setMessage(message)
.setDeepLink(uri)
.setCustomImage(Uri.parse(AppPrivate.Invitation.TRIP_INVITE_DEEP_LINK_IMAGE))
.setCallToActionText(context.getString(R.string.content_trip_invitation_cta))
.build();
However, when I receive the invitation via email on my desktop, it always goes to the Play Store listing, no matter what I've added to the initial deep link (DFL, AFL). Here's a sample of the link from the "call to action" button from the email:
https://a3d4u.app.goo.gl/i/225742434763-3bd2c2fa-45f0-4ed8-aca3-37760d27d971
I've not yet implemented the receivers in the android app to listen for incoming links, so I cannot confirm whether or not the deep link behaves appropriately on that platform.
Any recommendations or suggestions on what I'm missing with the desktop link are greatly appreciated.
Thanks!
You're actually wrapping a dynamic link in another dynamic link. Invites itself generates a dynamic link, which doesn't have your DFL parameter, so it is redirecting to the store.
You could try shortening the dynamic link you generate, and sharing via the regular share dialog rather than using Invites.
This is similar to questions asked several times before, but no matter what I read, I'm still confused.
I have a public Facebook page, like White Collar for example, whose activity feed I need to embed into my Android app. I understand how to get the app-id and app-secret, but I don't understand how to get the short-lived access token, which I understand is necessary to get a long-lived access token.
From what I understand, which can quite possibly be wrong, the user has to login through the app to get a short-lived access token, but I don't want any user to have to login to view the activity feed.
Once I have that, how do I then use it to bring this activity feed into my app?
The Facebook documentation for this is terrible so I need some help.
If it or anything else requires site-specific permissions, I have access to the site in question.
Thanks!
To get the activity feed of a public Facebook page, like White Collar, follow these steps:
1) Get your App-id and App-secret by choosing an existing app or creating a new one at this url:
https://developers.facebook.com/apps/
2) Get an access token by making a GET request to this url:
https://graph.facebook.com/oauth/access_token?client_id=" + APP_ID + "&client_secret=" + APP_SECRET + "&grant_type=client_credentials
3) Get the page-id of your fan page. To do this, you need the page-name. Go to your fan page on facebook and look at the url. It will have this form:
https://www.facebook.com/{fan-page-name}
Once you have that, make a GET request to this url:
https://graph.facebook.com/{fan-page-name}?access_token={access-token}
It will return a bunch of JSON. You're looking for the first "id" element. This is your page-id.
4) Get the fan page JSON data with a GET request to this url:
https://graph.facebook.com/" + page-id + "/feed?access_token=" + URLEncoder.encodeUTF8(access-token)
To avoid having exceptions thrown, I had to use URLEncoder.encodeUTF8().
The data you're looking for is under the "data" element.
I wasn't able to find anything that would do the JSON parsing of the Facebook feed for me, but I did find this tutorial that will do a lot of the formatting for you to make it look like Facebook.
Hope that helps anyone else trying to do this.
I am using Easy Facebook android SDk v2.3. I could successfully access a page and get details of page including number of likes.
I am trying to implement like button in the app using setLikes(String likes); method of Page class but getting confused with what is to be passed as the parameter.
Sample Code :
p = Global.graphApi.getPage("Page ID");
p.setLikes(String likes); //what should likes be replaced with, replacing it with user id didn't work
Any help on this is appreciated.
According to the facebook documentation, (Page), you cannot like a Page via Graph API, even though you can read the like count information.
User, have to press the like button himself to like the page.
The accepted answer here may help you: like android application page in facebook from application itself
I want to integrate an android app with facebook.
I've managed to fetch friends list and to post on wall on demand (a facebook url view is loaded and the user can post on wall whatever he texts).
I want, when the app is started and the user accepts the permisions, to post a message on wall that he is started to play my game without showing that url view for posting (an automatically post)
Can someone help me?
It's probably late and maybe you've got your answer for this question.
But for anyone else who need an answer:
First, you can use the Graph API, there is an example of how to post on
a wall.
But there is a restriction!!
Facebook is not allow us to enter a prefiil message!
The content of this message must come from the user itself!
Watch this video of Facebook on Platform Policy 2.3 Example and Explanation
The Wishlist Facebook app example is supposed to demonstrate adding custom objects to the Facebook open graph. I have managed to get the application so that it runs and creates a Facebook object with a graph ID. The problem is I don't see any of the custom object information I enter on the Android end of the app appearing at the Open Graph node associated with the returned ID, nor do I see this information appearing anywhere else on the internet.
The Android end the app seems to encode the information into a URL which is then added to a bundle and put in an HTTP post. For example when I entered the product name "baseball" along with some image the bundled URL was:
https://evening-frost-8481.herokuapp.com/Server/product.php?og%3Atitle=baseball&image=4f038f901dc31.jpg
When I examine the resulting Facebook aggregation it contains a link to the url below (note: there is no explicit reference in my app to the extension /Server/product.php which suggests Facebook may be receiving some of the information sent from my Android app.)
http://eveningfrost8481.herokuapp.com/Server/product.phpcode=AQAcvYSQQhesHLoXFHF9NUK2m__2_ye722T8lTfCs_9EKlgWp-ngUKls-fUet7FXUG6Gv8pbEpDuSATVpdsHUE7FcD6TmU
Is there anyone out there who has successfully implemented this demo who can give me some over view of how the custom data is supposed to get to the internet and finally Facebook?