I’ve accessed the fb->api method several times…but recently downloaded the latest SDK and now I’m getting some weird behavior. Here’s the code:
try {
include("facebooksdk/src/facebook.php");
}
catch (Exception $e) {
echo "$e" . "<br/>";
die($e);
}
$appId = 'xxxxxxxxxxx';
$appsecret= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$fb = new Facebook(array(
'appId' => $appId,
'secret' => $appsecret,
'oauth' => 'true'
));
$accesstoken = $fb->getAccessToken();
$me = $fb->getUser();
if(!$me) {
header("Location:{$fb->getLoginUrl(array('req_perms' => 'email,offline_access'))}");
}
**try {
$result = $fb->api(array('/me', 'GET'));**
print_r($result);
}
catch(FacebookApiException $e){
echo $e->getMessage();
}
My issue is when I attempt the $result…I get “UNKNOWN METHOD” returned (and occasionally some direction to base_facebook.php). Any ideas on this one? Can’t find good data anywhere on the net.
Are we not able to access by relative_url (I’ve also tried the relative_url=> method…no luck!). Ultimately I want to get DAU from this. Thanks!
Try just:
GETis the default method. And when you pass an array, you’re telling the Facebook SDK that you’re using a REST method, which obviously doesn’t exist, so that’s why you’re getting “Unknown method.”