Hier ein kleines Code Snippet um einen sogenannten "app access token" für Facebook API zu erstellen. Dieser wird zum Beispiel benötigt um eine App für die sogenannten "Live Updates" zu subscriben.
define('APP_ID', 'ENTER HERE YOURE APP ID');define('APP_SECRET', 'ENTER HERE YOURE APP SECRET');$accessTokenUrl = "https://graph.facebook.com/oauth/access_token?client_id=" . APP_ID . "&client_secret=" . APP_SECRET . "&grant_type=client_credentials";define('subscribeUrl'," https://graph.facebook.com/" . APP_ID . "/subscriptions" ); //"https://apps.facebook.com/" . APP_ID . "/subscribe";//include_once('config/config.php');define('POSTURL', 'https://graph.facebook.com/oauth/access_token');define('POSTVARS', "client_id=" . APP_ID . "&client_secret=" . APP_SECRET . "&grant_type=client_credentials"); // POST VARIABLES TO BE SENT// INITIALIZE ALL VARS$ch='';$Rec_Data='';$ch = curl_init(POSTURL);curl_setopt($ch, CURLOPT_POST ,1);curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVARS);//curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERScurl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL$Rec_Data = curl_exec($ch);$accessToken = explode("access_token=", $Rec_Data);/*** this here is the "App Access Token"*/var_dump($accessToken[1] );
Kommentare