0

我正在使用下面的代码来更新 facebook 中的用户状态。它在 2 个月前运行良好。现在问题是使用该应用程序登录 facebook 后需要花费太多时间来加载 nd 错误消息就像“这个网页有一个重定向循环”。请给出一个想法,使 tis 代码工作

 <?php
 //include the Facebook PHP SDK
 include_once 'facebook.php';

 //instantiate the Facebook library with the APP ID and APP SECRET
 $facebook = new Facebook(array(
  'appId' =>'id',
    'secret' =>'xyz',
    'cookie' => true
 ));
 $user = $facebook->getUser();

 if($user) {

    //do stuff when already logged in
 if( session_id() ) 
 {

 } else {
    session_start();
 }

 $access_token = $facebook->getAccessToken();

 $permissions_needed = array('publish_stream', 'read_stream', 'offline_access', 'manage_pages');
 foreach($permissions_needed as $perm) {
    if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0]     $perm] !            =      1 ) {
       $login_url_params = array(
     'scope' => 'publish_stream,read_stream,manage_pages',
     'fbconnect' =>  1,
     'display'   =>  "page",
     'next' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
    );
    $login_url = $facebook->getLoginUrl($login_url_params);
     header("Location: {$login_url}");
    exit();
    }
  }
   $accounts = $facebook->api(
  '/me/accounts',
     'GET',
  array(
  'access_token' => $access_token
   )
 );
    $parameters = array(
     'message' =>'hi ansari.....',  
      'link' =>'www.yahoo.com',
    'name' =>"vijesh",
    'caption' =>'',
    'description' =>"mydescription"
   );



   $newpost = $facebook->api(
 '/me/feed',
  'POST',
  $parameters
  );

   } 
    else 
    {
    $login_url_params = array(
  'scope' => 'publish_stream,read_stream,manage_pages',
  'fbconnect' =>  1,
  'redirect_uri' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
     );
      $login_url = $facebook->getLoginUrl($login_url_params);

           //redirect to the login URL on facebook
        header("Location: {$login_url}");
         $accounts = $facebook->api(
       '/me/accounts',
      'GET',
          array(
            'access_token' => $access_token
          )
       );


    $parameters = array(
  'message' =>'Hi gud evening',  
  'link' =>'www.yahoo.com',
 'name' =>"vijesh",
 'caption' =>'my Try',
 'description' =>"mydescription"
  );



    $newpost = $facebook->api(
     '/me/feed',
      'POST',
        $parameters
   );

      exit();
    }
   ?>

提前致谢

4

0 回答 0