Get Facebook app scoped user id LIKES - facebook-graph-api

I know you get a users "likes" from the graph api by doing
https://graph.facebook.com/v2.10/userid?fields=likes
However this only works with Real User Ids. What I don't understand is how is my app supposed to get the users "likes" if the App can't get the real User ID?
Originally I was testing this with my Facebook account and everything worked. But I'm now guessing this because I'm assigned as a developer to the App, I was get the Real User ID.

Related

facebook api, get access toling without login having user id

I'm trying to understand what is the best way to work with facebook user login. In my app in profile section it's possible for user to sync with facebook, and store it (I'm storing facebook user id in application database), and use GraphApi with provided access token in app afterwards. At this point all is fine.
But when user back to app some time later, to run some GraphApi call he need new access token, and I do not see a way how to get that access token without running user through the same facebook authentication logic with that facebook confirmation dialog.
So the question is it possible to get access token having pre-stored user id without running user again through authentication??? It's a bit weird from user perspective to see all the time that facebook dialog after he already login with facebook and save that once. Also, if facebook require always to confirm login, it seems like from app perspective it does not make sense to store id at all (any way it's possible to get it with each login)???
Also, what if I do not want for users of my app to easily change linked facebook account, but with that facebook pop up, user each time can login through different account. Is that means I need on app side afterwards compare returned id with a stored id and alert user, that he can't change already synchronized facebook account to some other?

How to kick off Facebook Messenger conversation with user

I've seen this use case a few times.
A user goes to a company's web site and places an order with the company.
User logs into Facebook.
Messenger window shows up that says order confirmation # and now there's a chat between you and the business.
I'm trying to figure out how this is done.
Of course, if the user has given the app permissions or there was some Facebook integration on check out, then presumably the company has captured the user id and can send messages.
Is there any possible way that a company can send a message to a user by simply knowing their e-mail address? I think FB ids are scoped to Apps so even if you knew the user's FB Id, the ID on your app would be different. Any ideas?
I did it with ruby on rails.Let me give my articles about messenger bot.
This link show from scratch. and it uses this gem to make it happen. These are so useful articles. if you have additional questions, please let me know.

social-auth gives "wrong" facebook id

I use django social-auth for facebook login and need to get facebook user id for using in facebook chat xmpp. Playing it manually, i knew that my id is 10000xxxxxxxxxxxxx but then noticed that social-auth holds another id: 77061xxxxxxxxx4
request.user.social_auth.get(provider='facebook').uid
Both of them work and redirect to my fb account when in browser but I can't use for facebook chat xmpp the one which social-auth has. Please advice.
It is not a wrong ID, since v2.0 you donĀ“t get the global ID anymore but only a so called "App Scoped ID". It is unique in one App and will stay the same, but you will get another one in another App.
https://developers.facebook.com/docs/apps/changelog

Is it possible to display Facebook user photos if someone isn't logged into Facebook?

I'm in the draft stage of designing a charity site for a friend of mine, and we'd like to be able to display photos of people who donate (they would have the choice of turning their photo on or off).
I'm used to logging people into another app of mine via Facebook, and retrieving their basic data.
What I'm wondering is - since the person viewing the site would be the only one logged into it, is it even possible to display photos of Facebook users who have donated ie can you retrieve a FB user photo if they aren't logged in?
If not, are you allowed, with the user's permission, to store their Facebook photo?
Thanks for your time and help.
Have a look at
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/picture/
It's stating
Because profile pictures are always public on Facebook, this call does not require any access token.
This means as long as you requested the public_profile permission upon Facebook Login, and stored the app-scoped user_id in your database somewhere, you can use this app-scoped user_id to generate the profile picture image sources as follows:
<img src="https://graph.facebook.com/{app_scoped_user_id}/picture?type=large&redirect=true"/>
and replace {app_scoped_user_id} by the real app-scoped user_ids in some kind of loop.

Facebook permissions - login flow

I am facebook development newbie and have problems with understanding login flow.
What I want to achieve:
I need access app user's pictures from the album created by the
application (preferably also when users are offline).
I run through facebook samples and stackoverflow questions and what I managed to do is:
I use facebook authentication with user_photos scope as follows:
however the script retrieving list of albums gets an "An active access token must be used to query information about the current user." error.
So I added:
Grant Permissions to Allow access to Photos and Albums
The scope is exactly the same, so I don't understand why after clicking that button retrieving the albums works.
The problem is that after refreshing the page, app recognizes that I'm a user who uses the app, but the albums are not accessible again.
How can I make app to get the permission to access pictures permanently?
I suppose it should be possible to access them also when the user is offline (if the album is public)?
The problem was that script accessing data was loaded faster than the user was verified by facebook. It worked with a button just because clicking a button gave application needed time buffor.