Reputation: 35
I've been spending 2 days on Google, looking for a way to retrieve Facebook posts by hashtag. I already know that the API doesn't allow anything with hashtags and I find it stupid, but that's it.
Now what I want to try is to get those posts through curl, but I'm not that good at it.
Let's say for example that you want all public posts containing #baseball.
When you're logged in, you can see them there: https://www.facebook.com/hashtag/baseball
So basically, I want to curl that URL to get the posts. But of course it doesn't work...
Here is the script I use:
$url = 'https://www.facebook.com/hashtag/baseball';
$http = curl_init($url);
$fake_user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3';
curl_setopt($http, CURLOPT_USERAGENT, $fake_user_agent);
$result = curl_exec($http);
As you can imagine, $result
is empty...
I've tried to get an access token before doing that, but even though I add it to the URL, it doesn't work.
Any ideas?
Upvotes: 2
Views: 8638
Reputation: 36
Use this URL: https://graph.facebook.com/search?q=YOURHASHTAGWITHNO#&type=post&limit=999&access_token=YOURMEGATOKENHERE
Use Facebook SDK + Facebook APP creator with API ID and secret to generate token.
Upvotes: 2