Facebook like count problems - facebook

I was trying to get a piece of information that is pretty standard and public: the number of likes of a page. However, facebook somehow managed to make this simple task very complicated.
I was trying to use graph API, but for some reason, it's required to have special permission called "Page Public Content Access", which is denied to almost everyone, or have managing permission of the site. In the first place, I don't understand why this is required for getting a piece of information anyone can get, even if not logged in.
Afterward, I was trying to get the like count of a page I created, but it seems that Facebook cannot find it.
It seems that before v5 it was quite easy. But now, it seems like a bug. I researched facebook's community, and some other people were complaining. A guy from facebook said that they'd work on it, but that was 4 months ago. He hasn't replied again.
Does anyone have any idea on how to get the number of like? Perhaps something that I missed?

<?php
declare(strict_types=1);
$url='https://www.facebook.com/zuck/videos/10111118208672491/';
$ch=curl_init();
curl_setopt_array($ch,array(
CURLOPT_URL=>$url,
CURLOPT_ENCODING=>'',
CURLOPT_RETURNTRANSFER=>1,
CURLOPT_SSL_VERIFYPEER=>0,
//CURLOPT_VERBOSE=>1,
CURLOPT_USERAGENT=>'bot',
));
$html=curl_exec($ch);
curl_close($ch);
// reaction_count:{count:100159}
$rex='/reaction_count\:\{count\:(?<result>\d+)/';
preg_match($rex,$html,$result);
$result=$result['result'];
var_dump($result);

Related

Is instagrams Rest API "https://api.instagram.com/v1/users/{user-id}" not working / removed?

I am using the Instagram Rest API for a simple application and I've hit a bumb.
The call https://api.instagram.com/v1/tags/{tag-name} works fine (I also have the ?accesstoken=XXXXX... appended).
But the call for basic user information is not working. Not in the developer console and not in the browser when modifying my own URL.
Has the method been removed? Is it broken? If no one has an answer for that; How do you contact Instagram to report the broken link?
Thanks to #CnapoB I managed to realise the call wasnt what I was looking for! And also he showed me the Instagram Endpoints doesn't show the easy way!
https://api.instagram.com/v1/tags/{tag-name}?access_token=ACCESS_TOKEN
might as well be
https://api.instagram.com/v1/tags/{tag-name}?client_id=CLIENT_ID
which means you don't have to have the user login to the application etc.
Thank you so much for this!
What I wanted to do was instead this: (example: tyrabanks)
https://api.instagram.com/v1/users/search?q=tyrabanks&client_id=CLIENT_ID&count=1

Deleting facebook user role in app when user hasn't yet accepted the invitation (pending) using facebook graph

As the title suggests, I'm having problems deleting users that have not yet accepted the role on my apps.
When I make the delete request:
https://graph.facebook.com/v2.3/{app-id}/roles/?method=DELETE&user={userId}&access_token={adminAccessToken}
I get the answer:
{"success": true}
But the user is still in the roles tab of the app with the "(pending)" tag beside.
Is there any other way to do this using facebook-graph?
That looks like a bug.
I’d suggest you go file a bug report and ask them to fix this. https://developers.facebook.com/bugs
(I don’t like giving short answers like this, especially if it doesn’t actually solve the problem. But if you want something to accept … ;-) If someone can come up with a better answer, that’d be fine by me.)

ColdFusion - OAuthException - This authorization code has expired. [code=100]

I am having a go at trying to get the Facebook API SDK for ColdFusion working.
https://github.com/affinitiz/facebook-cf-sdk
I have followed all the steps and it seems to work well (using only server-side login).
However, if I leave the page for say, an hour, when I return and refresh the page (which was showing my profile name and friends list) it shows up with an error that I am unable to get rid of, unless I clear the cookies.
Is there something I am missing with this FB login? Am I meant to be checking against something manually in order to persist the session?
Looking at my cookies, I have the following stored:
fbm_155030275875
fbsr_155030275875
CFID
CFTOKEN
It's all new to me, so I'm a bit lost. I can't see anything in the docs for the SDK about this and Googling the error brings nothing.
I have attached a screenshot of the error.
I'd appreciate any help you can offer!
Thanks,
Michael.
I'm not familiar enough with that particular project, but in general, your code should be requesting the various Graph API calls, and requesting the token as necessary. If the token has expired, you request a new one. I'd expect the facebook-cf-sdk product to do this, but again, I'm unfamiliar with it.
Good news is, the Facebook Graph API is just a series of HTTP calls. See my talk at NC DevCon for an example of logging in and making some graph calls: (a bit long; go to about the 1:42:00 mark)
http://textiles.online.ncsu.edu/online/Play/61d0900d63fd4c1cb862622d1c8e13521d?catalog=35211b84-031b-4a18-8875-506f09b9b3a7
GitHub repo:
https://github.com/bdcravens/ncdevcon2012-handson-auth (note the branches - check out the step4 branch)
These don't answer your question 100%, but they may be a good starting point for you.
Ok, I figured out how to solve this issue using a solution someone provided on Github. I just wanted to post this here in case someone else encountered the issue and wasn't sure how to solve it. In my case however, after I applied the solution from that post was I need to do a page refresh. Link below.
https://github.com/affinitiz/facebook-cf-sdk/issues/31

get facebook page full public photostream

there's only one similar question and it's not been answered. not for me at least.
There are public pages on Facebook, suppose i want to get their photostream ? their album pictures ?
I don't see how the Graph API allows me access since i can't get an access token, if i browse from my browser, NOT LOGGED IN, i can still see this public information, so how do i use the AI to access it.
BTW, i tried scrapping with python+mechanize and it's no go as if u get the regular we photo stream u get only partial, no all of it and the rest you need to scroll or to know how to build the same request the browser is building, but suprise suprise the JS doing the request is obfuscated pretty well...
Any help ?
in short it's not possible to do what i wanted annonymously, moreover at the moment, only some of the API works in the web site by accident only, if u are not logged in FB do not want to let u see any page and anyone, considering the last article about their cooperation with the US gov. it's not surprising.
In any case i just use grease money and FF to get a full page\album and then download the whole thing and i i need scrapping i'll do it on those pages with a script.
basically if i log in i can get a full page using the scripts in script monkey.... though script monkey is easier since he has the browser to parse all the data and works inside the browser...
I gave up after 3 weeks...

Tab links using only the page and app_id has stopped working, is there an alternative beyond querying Facebook each time?

A few days ago these type of links worked: http://www.facebook.com/pages/132456789?sk=app_132465798465 but now they give 404's.
The alternative is link to the namespace of the page like so: http://www.facebook.com/pages/foo/1456798324564?sk=app_134654689794 however to find out the link I'd need to ask Facebook for it, and it seem like since the namespace can change I can't just ask for it once.
Is there another way to use page and app id's to link to tabs without needing the roundtrip to Facebook?
I don't think that first format was ever used on Facebook, i'm surprised it worked.
As far as I can tell the 'name' part of a page URL is arbitrary, so just filling in something there will work, e.g.
http://www.facebook.com/pages/Tea/194040780316?sk=info
will also work as
http://www.facebook.com/pages/some_random_text/194040780316?sk=info