我需要你的帮助,因为我认为我已经达到了我的技能极限。我正在开发一个代码来使用图形 API 从 Facebook 获取用户数据并将其存储到 MYSQL 数据库中。到目前为止,我已经能够检索和存储我想要的所有东西,除了喜欢。
这是代码:
function getUserData() {
$fb_cookie = $this->getCookie();
if($fb_cookie) {
$url = 'https://graph.facebook.com/me?access_token='.$this->getAccessToken();
$data = json_decode($this->getDataFromUrl($url));
$fb['id'] = $data->id;
$fb['first_name'] = $data->first_name;
$fb['last_name'] = $data->last_name;
$fb['email'] = $data->email;
$fb['likes'] = $data->likes;
$fb['hometown'] = $data->hometown->name;
//tokens
$fb['token'] = $fb_cookie['access_token'];
$fb['token_expires'] = $fb_cookie['expires'];
return $fb;
}
}
尽管我在令牌中拥有“user_likes”权限。仍然无法存储或检索数据以将其保存到 MYSQL 中。
function update_members($criteria=array()) {
$fb_user_id = $criteria['fb_user_id'];
$fb_first_name = $criteria['fb_first_name'];
$fb_last_name = $criteria['fb_last_name'];
$fb_email = $criteria['fb_email'];
$fb_likes = $criteria['fb_likes'];
$fb_hometown = $criteria['fb_hometown'];
}
$sql = "INSERT INTO ".$GLOBALS['db_table']['members']."
(fb_user_id, first_name, last_name, fb_email, fb_likes, hometown)
VALUES ('$fb_user_id', '$fb_first_name', '$fb_last_name', '$fb_email', '$fb_likes', '$fb_hometown')";
$u1 = new MySqlTable();
$u1->executeQuery($sql);
到目前为止,我已经能够存储除喜欢之外的所有数据。在此先感谢您的帮助