dpxnrx11199 2016-01-21 12:11
浏览 284
已采纳

Facebook SDK通过PHP SDK撤销

I'm trying to make a web application with Facebook using PHP SDK I had not any problems installing and running the PHP SDK This is my login script index.php

<?php
session_start();
$app_id = '***************';
$app_secret = '******************************'; 
$my_url = 'https://www.domain.net/';
require_once __DIR__ . '/vendor/autoload.php';
$fb = new Facebook\Facebook(['app_id'=>$app_id,'app_secret'=>$app_secret,'default_graph_version'=>'v2.5',]);
$helper = $fb->getRedirectLoginHelper();
if (isset($_SESSION['facebook_access_token'])){
$fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
try {
  $fbresponse = $fb->get('/me');
  $fbuserNode = $fbresponse->getGraphUser();
} catch(Exception $e) {
  error_log("index.php: Exception",0);
  $permissions = ['email'/*, 'user_likes'*/];
  $loginUrl = $helper->getLoginUrl('https://www.sofiariders.net/fblog-callback.php', $permissions);
  echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
  exit;
}
?>

It works perfectlyq i'm getting logged in with the facebook but the problem is - the ID of my profile. From the $fbuserNode->getId() i'm getting the id 140261546352183 And Facebook doesn't open my profile by the URL https://www.facebook.com/profile.php?id=140261546352183

For example by using the site findmyfbid.com i'm getting another ID for the same profile - it's 100011050158477 and with that id Facebook successfully opens the URL https://www.facebook.com/profile.php?id=100011050158477

The question is - how can I cat my normal profile ID with the PHP SDK? And why i'm getting wrong id?

  • 写回答

1条回答 默认 最新

  • dourou9477 2016-01-21 12:17
    关注

    That other page is doing something that is not allowed: scraping. It gets your "real" ID directly from your profile page. In an App, you can only get an "App Scoped ID" - which is good enough to identify the user. You can just use the following URL: https://www.facebook.com/140261546352183 - it redirects to your profile.

    In other words: You can´t get the "real" ID anymore, and you don´t need it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。