Is it possible to track your Facebook notifications through an app other than Facebook's? I am looking to track the photos tagged of a person in facebook through an app.
Unfortunately, no. The Facebook sdk offers /user/notifications as an edge through the Graph API. That, however, requires the manage_notifications token which is unavailable to all Android, iOS, Web, and TV apps.
For your application, though, you're in luck (or at least I think you are). If you are trying to access all the photos of your user, you can use /user/photos to retrieve all the photos that the user is tagged in. If you follow the Reference Documentation, it'll give you back 25 photos. In order to grab more, and to 'page' through the data, use the limit and offset parameters as follows
Bundle params = new Bundle();
params.putString("limit","400");
params.putString("offset","800");
new Request( Session.getActiveSession(),
"/me/likes",
params,
HttpRequest.GET,
new RequestCallback() {
// handle results here
}
).executeAsync();
This request should give you all the information you need to know about the photo, but be sure to check out the documentation to get a list of all the fields available.
As a side note, you can also access albums to retrieve photos that the user has posted, which will also contain tagging information.
Related
I use facebook login in my app. Once the users are logged-in I can get their basic facebook info such as display name, email, and phot url.
I'd like to get their facebook friends list. I think I can get it "directly" with firebase but I don't remember how and I cannot find any info about it. I think I first have to tell Firebase to get friends list when people login with facebook, then I sould be able to get it with a method such as firebaseAuth.getCurrentUser().getFriendList().
Do you know how to get facebook friends list with firebaseAuth ?
Thank you,
Alex
It is feasible, but only the friends that also use your app. The trick is to add a scope to your login method. In Angular it looks like this
this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider().addScope('user_friends'))
That scope at the end is the trick. Then, you need at least two users that are friends on facebook to login. You will note the popup is different as it now asks permission for the user's friends.
The response will include an access token. Then you can use that token to request the user's friends that are also using the app with a GET request like this
https://graph.facebook.com/v2.11/{facebook_uid}/?fields=friends{name,id}&access_token={access_token}
Note I'm using a particular version, but you should change that to whatever you need.
generally obtaining user's all friends list from Facebook is not possible, they removed this option years ago, with API v2.0 introduction... more info about and useful suggestions HERE
there is an official FB API called Graph API and HERE you have some doc about friend lists
and the Firebase... well, this is Google's product and it have nothing to do with Facebook... You are probably using FB mail address for creating an account in Firebase service/database, but it is keeping only this data plus some additional attributes if set (like photo or visible name).
firebaseAuth.getCurrentUser() returns FirebaseUser object, which have THESE methods - like you see: logpass, name, photo url and only few more methods. no option for getting friends list, because there is no method to set them, and no possibility to get this list from FB lib/API
This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 8 years ago.
I'm trying to get all friends, of a user that logged into my application.
I can't use this API [friends]:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends
Because this API only returns any friends who have used the app making the request.
So I found this API [friendlist]:
https://developers.facebook.com/docs/graph-api/reference/v2.0/friendlist
Followed this answer, I got the friendlist list.
But I'm getting empty list when trying to get friendlist's members:
new Request(
session,
"/2692926356774/members",
null,
HttpMethod.GET,
new Request.Callback()
{
public void onCompleted(Response response)
{
/* handle the result */
Log.e(LOG_TAG,"Members: " + response.toString());
}
}
).executeAsync();
2692926356774 is my Acquaintances list id, I tried few other id's with the same result.
In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app.
In addition, in v2.0, you must request the user_friends permission from each user. user_friends is no longer included by default in every login. Each user must grant the user_friends permission in order to appear in the response to /me/friends. See the Facebook upgrade guide for more detailed information, or review the summary below.
The /me/friendlists endpoint and user_friendlists permission are not what you're after. This endpoint does not return the users friends - its lets you access the lists a person has made to organize their friends. It does not return the friends in each of these lists. This API and permission is useful to allow you to render a custom privacy selector when giving people the opportunity to publish back to Facebook.
If you want to access a list of non-app-using friends, there are two options:
If you want to let your people tag their friends in stories that they publish to Facebook using your App, you can use the /me/taggable_friends API. Use of this endpoint requires review by Facebook and should only be used for the case where you're rendering a list of friends in order to let the user tag them in a post.
If your App is a Game AND your Game supports Facebook Canvas, you can use the /me/invitable_friends endpoint in order to render a custom invite dialog, then pass the tokens returned by this API to the standard Requests Dialog.
In other cases, apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission).
For apps wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the new Message Dialog on iOS and Android.
I'm trying to get an Android app to post highscores to Facebook, similar to how Angry Birds on Facebook does (it get's displayed on Timeline and shows up in the Ticker too). Keep in mind that this game runs only on Android and has no FB Canvas application.
Currently the steps I take for posting the high scores are the following:
Authenticate the user via FB when login buttons is pressed, request only publish_actions permissions - works
Request the user id by calling "/me" via FB SDK and saving the id in a variable - works
Send a POST request via Facebook SDK when the users presses "Score 100 points", with the following code: - works (logs true from the call)
Bundle params = new Bundle();
params.putString("score", "100");
// appAccessToken is temporarily a constant
facebook.setAccessToken(appAccessToken);
String response = "null";
try {
response = facebook.request(userId + "/scores", params, "POST");
} catch (IOException e) {
e.printStackTrace();
}
// Logs true if successful
Log.d(TAG, response);
Open Facebook to see updates from the game, but nothing is displayed anywhere, unlike Angry Birds which shows up on your timeline and shows the highest score - fail (no record of any high scores anywhere
Some more information you may need:
Category of application is set to Game
Type of application is set to Web (Native didn't allow me to properly post a new score)
The user I'm trying with is the owner of the application
Tried the above steps with both sandbox on and off
If I call https://graph.facebook.com/USER_ID/scores with the appropriate access_token and user id, I get the previously sent 100 point score as a response, so the score posting seems to work
The question is why doesn't it show up anywhere in the feed/timeline/ticker. Am I missing something?
According to the documentation and the official tutorial, you're published your scores properly. So, enter our next question: why isn't it showing up on your user's Ticker or Timeline?
The answer is, the means with which games like Angry Birds publish high scores is actually blended between the score mechanism and posting directly to a user's stream. Facebook controls the story types and distribution under which scores will be published, so your app isn't guaranteed to generate a new story item every time you post a score to the site. Quoting a primary source:
Facebook says the stories that get the most clicks, likes, and
comments will get more distribution in News Feed and on Timeline.
Fortunately, you have a recourse if the user allows it. If you believe your user cares very much about having their high scores published, you can ask for permission to post to their stream directly and do so with your own custom messages. More information can be found here.
(Additional reference)
I want to upload a foto from my android app to a facebook fan page using the facebook API.
When i look in the hackbook android example app (link). the code looks as following to a upload photo:
Bundle params = new params.putString("url",
"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); params.putString("caption",
"FbAPIs Sample App photo upload");
Utility.mAsyncRunner.request("me/photos", params,
"POST", new PhotoUploadListener(), null);
This code works, it posts the photo on my own facebook page. But i don't want the photo to be posted on my page but on a fan page.
As explained in the facebook documentation 'me' could be changed with a facebook User_ID. I tried changing the "me/photo" in "[fanpagename]/photo" or "[fanpageID]/photo", but that did not work. when i used the username i got an error, when i used the ID it post the photo on my own page. In the graphAPI photo documentation (link) no example or explanation is givin on how to upload a foto on fan page.
also the
params.putString("to", [fbid]);
does not work.
Any suggestions?
I have been busy with this research for three full days and did not find the answer for my problem. But i think i have an explanation for it.
if a user posts a photo to friend/fan_page with the official android FB app it uses a "feed" with a picture(url-link). The user can't see on his own wall that he actually shared or posted a picture on the friend/fan_page. (for example: "Bob - posted a photo on CocaCola")
This is probably the reason why the function is disabled because developers could use this to send photo's to all kinds of friends/fan_pages without the user being aware of it.
I came to this hypotheses because i found a sort of work around. First upload the photo to users own album. get the URL of that photo and then post a "feed" on the friend/fan_page with a picture(url-lnk). Facebook then gave this error: "FBCDN image is not allowed in stream" in other words, you can't use photos that are on FB website domain to link to. So I think there is quite a bug/lazyness in the facebook developement departmet :P which is a pity because it is a nice socialnetworking function for mobile apps.
You are on the right track, but to publish photos to a Page you will need the publish_stream and manage_pages permissions, and the Page Access Token to prove you have them. You can read more about this here:
http://developers.facebook.com/docs/reference/api/page/#photos
http://developers.facebook.com/docs/reference/api/page/#page_access_tokens
Some example code (using the PHP SDK, but the logic should be the same in any language) is here: https://stackoverflow.com/a/7222078/164439
Update:
If you want to post to the Page's Wall/Feed (without being a Page Admin), you can do that without the Manage Pages permission and the Access Token stuff.
But it's different than publishing a Photo object to the Page's Photos collection, which is what I thought you asked. You actually want to do a regular Post to the Page, with a Picture attachment.
Here are some resources to do this:
Facebook Post API: http://developers.facebook.com/docs/reference/api/post/
http://facebook.stackoverflow.com/questions/691425/how-do-you-post-to-the-wall-on-a-facebook-page-not-profile
http://facebook.stackoverflow.com/questions/5756474/post-to-facebook-page-wall
Using Facebook Graph to simply post a wall message with just javascript
Good luck!
I am trying to let users "like" a Facebook fan page from within an Android app. I am able to successfully "like" objects such as wall comments using code like this,
mFacebook = new Facebook(APP_ID);
SessionStore.restore(mFacebook, this);
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
Bundle parameters = new Bundle();
mAsyncRunner.request(COMMENT_ID + "/likes", parameters, "POST", new MyRequestListener(), "");
However, if I put in a page id rather than a comment id, I get this error message in the Facebook response,
Response: {"error":{"type":"OAuthException","message":"(#200) App does not have permission to make this call"}}
I am obtaining both the "publish_stream" and "offline_access" publishing permissions at login, and they are given to the Facebook object with SessionStore.restore().
1) Does Facebook let apps "like" fan pages?
2) If so, any ideas on what I am doing wrong?
Thanks,
Matt
The Facebook documentation for Pages has been updated and is current (see https://developers.facebook.com/docs/reference/api/page/). You cannot like a Page via the Graph API, even though you can read the like count information.
As other answers say, it is not possible to 'like' pages via the Graph API.
The confusion in this topic comes from the API documentation, where is says You can comment on or like any object that has a /comments or /likes connection (The key term here is connection)
Going a little deeper:
Any object (in this case a Page), has a number of Fields and Connections. Fields are basically used to access the object information and Connections are used to perform operations in that object.
In sum, a Page doesn't have a /likes Connection, but it has a /likes Field, reason why we can get the number of likes of a given page, but we cannot like a page.
Unfortunately, as far as I know so far, you can't like Pages via the API. You can render a Like button via a web view, but I think you're out of luck here at least. You can (as you note) like comments and posts, but pages still require direct user interaction.