dro59505 2012-07-26 05:07
浏览 32

保持与Facebook的联系

I am currently developing in social engine in zend framework. Social engine has this built in plugin that let you stay connected to facebook even you are logged out to facebook site. So when you're posting status in my social engine site, it will still be posted on your wall even you're not logged in facebook site(I mean here in facebook.com) but I don't know how to do this in my custom widget in social engine that's why I thought I should just use the Facebook SDK.

I was successful using Facebook SDK but the problem is that it asks the user to login every time the script detects that the user is not logged in facebook.com . How to solve this??

I can actually retrieve the user details like openid, facebookemail. Yeps, that's only the thing I know :(

  • 写回答

1条回答 默认 最新

  • dongnong3019 2012-07-27 10:02
    关注

    I've developed same kind of application in Zend-Framework. I've used Facebook/PHP-SDK with oAuth 2.0.

    In this case you need to save access tocken in your database for the particular user. and with that access token you can get any data as well as post to. Yes for that you need to grant necessary permission from the user for your Facebook APP.

    Here is the two function that I've used in my application to fetch the access token , extended it and store in the database.

     /**
         * Getting User Acess Tocken , extended it and save it in to database......
         */
        public function getAccessToken($user_id,$fb_account_id)
        {
             $access_token=$this->facebook->getAccessToken();               
             $extended_access_token=$this->getExtendedAccessToken($access_token);                
            /** 
             * To save Access tocken and other necessary option
             */  
            $usr_bus_model = new Application_Model_UserBusinessAccounts;
    
            $usr_bus_model->loadAccount($user_id,'Facebook',(int)$fb_account_id);
    
            $usr_bus_model->details=$extended_access_token;
            $usr_bus_model->save();
    
            return $extended_access_token;
        }
    
         /**
         * Exrending User Acess Tocken.....
         */
    
        public function getExtendedAccessToken($access_token)
        {       
    
            $token_url="https://graph.facebook.com/oauth/access_token";
            $params=array('client_id'=>self :: appId,'client_secret'=>self :: appSecretId,'grant_type'=>'fb_exchange_token','fb_exchange_token'=>$access_token);
    
              $response = $this->curl($token_url,$params);
              $response = explode ('=',$response);
              $response = explode ('&',$response[1]);
              $response = $response[0];       
              return $response;
    
        }
    

    Hope it helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭