Ok so i've tried the following:
FB.api("/me", {fields: "picture"}, function(response){
console.log(response);
});
And i'm trying to work around http://graph.facebook.com/USERNAME_OR_USERID/picture since obviously i don't know the users ID prior to authenticating.
All i want is a "modern" feel within the website, so i'd like to present the user with his or her's profile picture on the "login" div presenting the facebook login button. Is this possible? I know that Facebook and their graph api prohibits most such features but i would hope that a public profile picture would be accessible through the graph API..
I've Googled around and all the solutions say "use the USERNAME in the URL and you're fine" but i'm not, so to clear out any doubts, is this possible?
Error message: An active access token must be used to query information about the current user.
You can get everyone's Facebook profile picture without authentication.
You just call http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large. This URL redirects you to image URL.
Type may be normal,small or large.
I also have questions for you:
How do you want to display the picture of someone without knowing who he/she is?
How can you guess which account the visitor will use to connect?
It looks like you want to know whose Facebook account was lastly connected on the browser of your visitor. Technically, you would want to read another site's cookies, which is 1) not allowed 2) impossible.
Several additional things you need to know:
http://graph.facebook.com/USERNAME_OR_USERID/picture is a public way to retrieve someone's photo. You don't need a token for that. What else do you need?
Using FB.API("/me", ...) from the JS SDK implies that "me" represents the connected user. It cannot just be used alone.
By the way, identical questions have already been answered and accepted:
Facebook app without prompted authentication
Get Facebook user's profile picture prior to authenticating app
Why would you hope the impossible?
Related
I am using ngx-facebook for implement FB page like. I want to know if my FB page was liked or not to perform some action on basis of response.
I followed "https://www.npmjs.com/package/ngx-facebook" tutorial to implement FB like.
Rewarding users in any way for liking a Page is not allowed. The only way to know if a user liked a Page is to authorize that user with the user_likes permission. After that, you can check if the Page is liked. You will not get that permission approved by Facebook though, if you reward users for liking, or gate content behind likes.
TL;DR: It´s not possible and not allowed for your use case.
More information: https://developers.facebook.com/docs/apps/examples-platform-policy-4.4
So I was very happy when Facebook approved my Chrome Extension app. Basically, it allows you to import your data from facebook into the local_storage in Chrome, then you can easily search your old posts. While it works like a charm for my account, when I switch to another account, login, approve the Facebook request for permissions, my user_feed data is empty. I am at a loss.
I am able to get user info, the image of the user, his/her name, etc. and I am able to retrieve an access token. But, when I make the call to the feed, it comes back empty:
https://graph.facebook.com/me/feed?access_token=EAAcu...&expires_in&limit=50&offset=1&fields=message,likes,story,created_time,link
(I have also tried injecting the ID for "me"). Again, this works great when it's my FB account (also the developer account). So, I don't think it is my code, the only thing that changes is the user...
Perhaps it takes a certain amount of time for the Facebook API to work even after Facebook approves your permissions request??
Use the Access Token Debugger Tool to see if the access token that you are getting back has user_posts permission listed under "Scopes". If it is not present, then you cannot use that access token to fetch the user's feed.
Note that user_posts permission requires approval prior to usage. If you are not approved, it will only work for people who have admin/developer role in your app.
Got it. I didn't see this anywhere in the documentation, but in addition to having your app's permissions approved by facebook, you must also include the scope as a query parameter:
https://www.facebook.com/dialog/oauth?client_id=${appId}&scope=user_posts&response_type=token&redirect_uri=http://someresponse.com
If anyone sees this in the documentation, please let me know.
I am using passport.js to let users log in.
I am wondering if it's possible to create a link to their profile on their social media account?
For instance, when logging in using Facebook, I can get an ID, but the link https://www.facebook.com/profile.php?id=__ID__ doesn't work.
Maybe it's not possible at all since some Facebook users might have their Facebook profile hidden even though they use their account as login for other websites.
From what i know, this is not possible using passport at least.
The reason why the link doesn't work is that the ID returned by Facebook is always app specific so different apps would get different IDs for the same user. So you don't get the "official" ID of a user which you could use for building the URL.
However, the Facebook API returns a link to a users timeline which should be the one you are looking for (https://developers.facebook.com/docs/graph-api/reference/user/). But from what i see in the documentation of passport, this information is not returned. So if you want to get the link you need to work with the Facebook API directly.
I know at first this sounds evil, but I'm not trying to be at all. I'm only trying to get the users Facebook ID without having to connect to FB. I basically want to unique the user on my site by their social id.
If you use facebook's comments feature, without being connected, they have your ID and picture. The picture is easy because it's just a URL, but that ID, how do they get it?
Obviously they use iFrames, and maybe that's where the story ends. Because of cross domain scripting I can't get into that iFrame to grab the ID. This is a case where it's so close yet so far away. I can get there via dev tools but I can't get that ID via JS.
So the question is, does anyone know a way to get a users facebook ID without having to connect to facebook first.
Thanks!
Sorry but you cannot do this, as Facebook does not expose this data without explicit user consent.
I am building a very small webpage to use in a kiosk stand. The goal is to let people "Like" a facebook page on location with a touchscreen.
Users have to login first to like a page, so Facebook will come up with their regular Login popup, which works like a charm. When the user logged in, the page is liked (since they clicked the "Like"-button) and the user should be logged out again (since no-one wants to be logged in on a public computer). The page should reload after that.
Now this is possible with the Javascript API from Facebook. They have an event listener that calls a function when a user likes a page. I just have to call FB.logout() when that event triggers :) .
Unfortunatly, it isn't working for me. I could be very dumb, or the Facebook API is bugged.
My code:
window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create', function(response) {
FB.logout(function(response) {
window.location.reload();
});
});
}
But this doesn't work, and I think the problem lies in the Login part from Facebook.
Does anyone has any experience with this? It should be very simple, but I can't get it to work...
Some things I have tried:
Prompt a normal login - Possible, but it says that my app needs access to some information. Really the only thing I want to do is get users to like a page.
setTimeout loop - Tried this, but the Facebook Login seems to stop Javascript as a whole on my page?
EDIT: I know that it is a bad idea for people to insert their credentials into a public computer, but the customer wants it this way. There is also a QR-code which links to the Facebook page, but that doesn't solve my problem :) .
TL;DR: Facebook Javascript callback from the "Like"-button works when a user is Logged in, but fails when a user has to log-in via the Facebook pop-up.
Unfortunatly, it isn't working for me. I could be very dumb, or the Facebook API is bugged.
Nope. The problem lies in your approach, resp. the concept.
FB.logout only works with an active access token (since otherwise, any site I visit on the net could log me out of Facebook, and that would be hugely annoying).
But since the user does not connect to your app, you don’t have an access token.
Prompt a normal login - Possible, but it says that my app needs access to some information.
That is the only way you will get an access token, and since the only way you can use FB.logout.
(And if the user logs in to Facebook, but then denies connecting to your app, again you will not have an access token, so you can’t log them out in that case either.)