Autor | Zpráva | ||
---|---|---|---|
zdenek Profil |
#1 · Zasláno: 2. 11. 2012, 21:17:52
ahoj, vím, že toto téma tu už bylo řešeno, ale mě to ne na ne fungovat, tak jsem si řekl, že se tu zeptám. :)
mám kód souboru fbaccess.php: <?php //Application Configurations $app_id = "ee"; $app_secret = " ff"; $site_url = "gg"; try{ include_once "src/facebook.php"; }catch(Exception $e){ error_log($e); } // Create our application instance $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, )); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based // on whether the user is logged in. // If we have a $user id here, it means we know // the user is logged into // Facebook, but we don’t know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if($user){ //==================== Single query method ====================================== try{ // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); }catch(FacebookApiException $e){ error_log($e); $user = NULL; } //==================== Single query method ends ================================= } if($user){ // Get logout URL $logoutUrl = $facebook->getLogoutUrl(); }else{ // Get login URL $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'read_stream, publish_stream, user_birthday, user_location, user_work_history, user_hometown, user_photos', 'redirect_uri' => $site_url, )); } if($user){ // Proceed knowing you have a logged in user who has a valid session. //========= Batch requests over the Facebook Graph API using the PHP-SDK ======== // Save your method calls into an array $queries = array( array('method' => 'GET', 'relative_url' => '/'.$user), array('method' => 'GET', 'relative_url' => '/'.$user.'/home?limit=50'), array('method' => 'GET', 'relative_url' => '/'.$user.'/friends'), array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6'), ); // POST your queries to the batch endpoint on the graph. try{ $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST'); }catch(Exception $o){ error_log($o); } //Return values are indexed in order of the original array, content is in ['body'] as a JSON //string. Decode for use as a PHP array. $user_info = json_decode($batchResponse[0]['body'], TRUE); $feed = json_decode($batchResponse[1]['body'], TRUE); $friends_list = json_decode($batchResponse[2]['body'], TRUE); $photos = json_decode($batchResponse[3]['body'], TRUE); //========= Batch requests over the Facebook Graph API using the PHP-SDK ends ===== // Update user's status using graph api if(isset($_POST['publish'])){ try{ $publishStream = $facebook->api("/$user/feed", 'post', array( 'message' => 'Check out MotyckaZdenek', 'link' => 'http://motycka.php5.cz', 'picture' => 'http://motycka.php5.cz/images/facebook-logo.jpg', 'name' => 'motycka.php5.cz', 'caption' => 'motycka.php5.cz', 'description' => 'A Technology Laboratory. Highly Recomented technology blog.', )); }catch(FacebookApiException $e){ error_log($e); } } // Update user's status using graph api if(isset($_POST['status'])){ try{ $statusUpdate = $facebook->api("/$user/feed", 'post', array('message'=> $_POST['status'])); }catch(FacebookApiException $e){ error_log($e); } } } ?> poté mám i soubor index.php, který mi zobrazuje akorát výsledky, ale nefunguje mi přihlášení. pořád mi to zobrazuje, že nejsem přihlášen, i když přihlášen jsem. Díky za nějakou odpověď. :) |
||
Časová prodleva: 12 let
|
0