get who likes facebook post by php code - php

i want to get who like facebook post then and store it in php variable ... then look for specific name i want
if it is about facebook photo i can use this
$url = 'graph.facebook.com/photoid'
and then i use the code
file_get_contents($url);
and then search about the name who liked the photo
but in post there is no graph to get who like post
i tried to put the whole link like
$url = 'https://www.facebook.com/AmrKhaled/posts/10152183719946165'
and then i use the code
file_get_contents($url);
but not found the name ... and if i var_dump($filegetcontent) and search my self no name is found
i need to know who like my post by php code ?? thanks

The problem is not the user agent because you shouldn't be scraping the page.
The id in that post is at the end
http://graph.facebook.com/10152183719946165
You just need a valid access token to retrieve it.
To read a Page you need:
an app or user access token for public and non-demographically restricted pages
a user access_token for restricted pages that the current user is able to view (no special permissions required)

Related

How Can I get the facebook user id in order to get profile picture?

I just want to put a facebook user profile picture in a simple webpage.
I have read a lot about this, and I found the same answer, "Facebook Api 2.2" cannot query users by username:
http://graph.facebook.com/username
just by user id, but How Can I do this without the api?, I also read that I have to make the user sign into facebook account in order to get the user id, something like that, but it's just a simple webpage.
I was trying to do this in php.
//this is just for showing the page
$homepage = file_get_contents('https://www.facebook.com/ricardo.citerio');
var_dump($homepage);
Here my idea was to get the page and search for this keyword "fb://profile" in the code and catch the first X characters from that point:
fb://profile/621673493
//I can get this by opening the source code of
https://www.facebook.com/ricardo.citerio
but the big issue is that file_get_contents goes to the index page "www.facebook.com" not to "www.facebook.com/username", with any other page works fine but not with facebook.
You can't and shouldn't do it without the API. You must authenticate users in order to use their data. Please read Facebook Platform Policies here: https://developers.facebook.com/policy/

accessing data in GET account/verify_credentials in twitter with php

When I use the method in the twitter API
$content = $connection->get('account/verify_credentials');
it returns a json that has all the data of the user
I know that I can access for example the Screen Name like this :
$content->screen_name
but how can I access Country and Country Code ...
You can access the users' location with the location field. You will have to guess the country (and its code) from this.
For further documentation, see the corresponding Twitter Developers page : https://dev.twitter.com/docs/platform-objects/users.

How can i get the profile picture of a user who have registered my website via the facebook social plugin

I have a registration plugin embeded via an iframe on my website, The registration plugin works fine , I am also able to get the unique user_id of each user by using the following line of code in the signed_request file which can be located here
The line of code i use to get the user_id is: $response["user_id"];
Now that i have a unique id of each user, i want a way by which i can get the link to the profile image of that user, i know i can get the thumbnail of the profile picutre
using open graph,
But i am looking for a way by which i can get the link to the complete or the original profile picture, not the thumbnail.
Is there a way this can be done? Using open graph or something like that?
You need user_photos permissions first. Then something like this should do it:
SELECT cover_object_id FROM album WHERE owner=me() and type='profile'
Substitute me() with the user you are querying for.
It returns the photo object that you can then use to pull the full version from.
Make an API call to /user_id/?fields=picture using the access_token in the same signed_request

How do I display visitor fullname on my facebook fan page welcome tab?

I have created my fan page using Page Tab.
Now I want to display visitor Full Name on that page.
Example : Hello Fullname
It's possible without authentication?
I suggest using the Javascript SDK to achieve this, here's the documentation
... and in answer to your second question, you'll need to get authorisation of use user for your app to make any Graph API request.
You'll need to get the user's name by doing an API request to /me?fields=name get the username.

facebook, how to get the facebook uid from any facebook page?

how to get the facebook uid off a page, when you visit that page?
if i go to a page of my friend or anybody, i need to know the uid. i can get mine like this:
$signed_request = $facebook->getSignedRequest();
$user_id = $signed_request['user_id'];
edit:
well i have this app and i need to pull the fakebook url into the application so i can grab the id from there.
if i try, i get the app id:
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
what i need is to grab the fb link address,like #Rufinus said, something like https://graph.facebook.com/cocacola
any ideas?
thanks
I'm still not 100% on what you're asking. It seems like you're definitely looking to get information about a page as opposed to a user.
If you have an app, on a page in a tab like on the coke page, then we'll pass you a signed request that contains the id of the page. You can then pass that to https://graph.facebook.com/{ID} and you'll get the same result as passing https://graph.facebook.com/{vanityUrl}.
What you want to access from the signed_request is $signed_request['page']['id'].
In that same page array, you can also pull ['page']['liked'] which will tell you if the viewer has liked the page. And finally you can access ['page']['admin'] which will tell you if the viewer is also an admin of that page.
If that doesn't answer your question, edit it a little more and i'll re-answer.
you just can call https://graph.facebook.com/cocacola no token needed.

Categories