 |
|
Code (PHP)
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$appid."&redirect_uri=".$url."&client_secret=".$app_secret."&code=".$code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$tmp1 = explode("&",$response);
$tmp2 = explode("=",$tmp1[0]);
$access_token = "";
if(sizeof($tmp2)==2){
$access_token = $tmp2[1];
}
$url = "https://graph.facebook.com/me?access_token=".$access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$profile = json_decode($response);
print_r($profile);
จากโค้ดด้านบนตอนที่ใช้กับ app ที่มี api เป็น v2.2 ตอนปริ้นดูผลลัพธ์มันจะได้ผลลัพธ์หลายค่า แต่พอเอามาใช้กับ app ที่ผมสร้างใหม่วันนี้ที่มี api เป็น v2.5 ปรากฎผลที่ได้จะมีแค่ id กับ name ผมจะต้องแก้ไขยังไงเพื่อที่ดึงข้อมูล email กับ gender ออกมาได้
Tag : PHP, WebService, Windows, Web Service
|
ประวัติการแก้ไข 2016-02-25 17:35:31 2016-02-25 17:36:54
|
 |
 |
 |
 |
Date :
2016-02-25 17:33:54 |
By :
funrun |
View :
989 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |