Reputation: 105
I am attempting to access the results of a search on Facebook via PHP curl so I can write information about the search results into a database and check for incremental changes. The code is below, and I can get it to work similarly by pulling my pages name and count of likes,
<?php
function get_fb_data($get) {
define("TARGET", "https://www.facebook.com/search/".$get."/likers");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TARGET);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$exec = curl_exec($ch);
return $exec;
curl_close($ch);
}
$fb = get_fb_data('506764276135128');
echo '<pre>';
print_r($fb);
echo '</pre>';
?>
The Facebook search does rely on being logged in to function, so I might have to pass user credentials along with an app key to access the results. However, I am hoping not as it has become extremely difficult and confusing to navigate through the App Developer section of the site and get approval for an app.
What I would like to pull off the page is the number of results, and the name/profile id for each result.
Upvotes: 0
Views: 929
Reputation: 74014
That would actually be scraping and is not allowed on Facebook. Use the Search API instead (see the section about "Searching").
It does not offer the same functionality as the Graph Search that is integrated in Facebook, but it is the only permitted way and you can search for Pages, Users, Events, etc).
Upvotes: 2