我想在带有 Jquery ajax Load 的 facebook 应用程序中显示带有 FQL 的朋友列表。我已成功加载用户朋友列表,但有时会出现类似这样的错误:致命错误:未捕获的 OAuthException:必须使用活动访问令牌来查询有关当前用户的信息。我该如何处理这个错误?
这是我的 javascrpit 代码,我使用 CodeIgniter :
$('#boyslist').load('friendslist/boyslist', function() { //some callback script });
$('#girlslist').load('friendslist/girlslist', function() { //some callback script });
这是我的控制器:
function boyslist($offset=0) {
$data['friend_record'] = $this->Facebook_model->getfriendslist('male', 0);
$data['boy_count'] = $this->Facebook_model->countAllFriends('male');
$data['gender'] = 'male';
$this->load->view('pages/v_malelist', $data);
}
function girlslist($offset=0) {
$data['friend_record'] = $this->Facebook_model->getfriendslist('female', 0);
$data['girl_count'] = $this->Facebook_model->countAllFriends('female');
$data['gender'] = 'female';
$this->load->view('pages/v_femalelist', $data);
}
这是我的模型:
function getfriendslist($gender, $offset) {
$pos = 0 + $offset;
$limit = 10;
return $this->facebook->api(
array( 'method' => 'fql.query', 'query' =>
" SELECT uid, name, pic, sex, relationship_status FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) and sex='".$gender."' order by name limit ".$pos.", ".$limit." " )
);
}
之前谢谢。