<?php
/**
* facebook.class.php
*/class Facebook
{
public function __construct() {}public function search($query)
{
$curl = curl_init(‘https://graph.facebook.com/search?type=post&q=’.urlencode($query));// Tell curl to return results and not output it
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);// Execute curl and store results in $result
$result = curl_exec($curl);// Close connection
curl_close($curl);// Return the results as a decoded JSON object
return json_decode($result);
}
}?>
Tag: facebook
Facebook Graph API search with file_get_contents
$content = json_decode(file_get_contents(‘https://graph.facebook.com/search?q=xiaokyun&type=post’));