来自我和朋友的Facebook活动

时间:2012-02-29 13:43:25

标签: php facebook api codeigniter facebook-fql

  

可能重复:
  FQL returns “Requires valid signature”

我之前从未在论坛上问过问题,但似乎第一次出现在所有问题上!

我正在尝试在我的网站上运行多个查询,但它一直给我一个错误:

  

[ “ERROR_CODE”] => int(104)[“error_msg”] => string(24)“需要有效签名”

我认为这是由于无效的访问令牌,我不明白,因为它是正确的。我已经包含了从用户那里获取offline_access的权限。

这是我的代码:

class Facebook_model extends CI_Model {

    private $_fb_config = array(
    'appId' => 'MY_APP_ID',
    'secret' => 'MY_APP_SECRET',
    'fileUpload' => TRUE
);
private $_user = NULL;
private $_loginUrl;
private $_logoutUrl;
private $code;


function __construct() {
    parent::__construct();

    $this->load->library('facebook', $this->_fb_config);

    $this->_fb_config += array(
        'loginUrl' => site_url('facebook_functions/login'),//facebook->getLoginUrl(),
        'logoutUrl' => $this->facebook->getLogoutUrl(array('next' => base_url())),
        'code' => $this->facebook->getAccessToken()
    );
    $this->session->set_userdata('fb_config', $this->_fb_config);

 function get_events(){
  try { $access_token = $this->_fb_config['code'];
        $queries = '{"query1":"SELECT uid,name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me())","query2":"SELECT uid,message FROM status WHERE uid IN (SELECT uid FROM #query1)"}';
        $multiquery = "https://api.facebook.com/method/fql.multiquery?queries=" . urlencode($queries) . "&format=json&" . $access_token;
        $fql_obj = json_decode(file_get_contents($multiquery),true);
        return $fql_obj;
      } catch (FacebookApiException $e){
        error_log($e);
        echo($e);
        //return false;
    }
 }
 }

0 个答案:

没有答案