duanjie3267 2012-01-10 16:12 采纳率: 0%
浏览 55
已采纳

移动应用程序如何使用API​​并证明其想要修改的Facebook ID已登录并在Facebook上授权?

I am using the Facebook PHP SDK in a server-side API which is used by several mobile apps (iOS & Android) and a website to read/write data to the database.

I cannot see any reason why the web version will not work because the sessions set by Facebook can be read from the browser via the SDK.

So if I am using:

$facebook = new Facebook(array(
  'appId'  => 'xx',
  'secret' => 'xx',
));

// Get User ID
$user_id = $facebook->getUser();

And the $user_id is set, then I can get the user information for the logged in user. This means that when I am saving, updating or getting records from the database they are guaranteed to only be for the logged in user and cannot be spoofed.

How to securely communicate from mobile web app to server using Facebook PHP SDK

So, how would this be replicated for a mobile application? How can the mobile application use the API and prove that the Facebook ID it wants to modify is logged in and authorised on Facebook?

  • 写回答

1条回答 默认 最新

  • dongtao4787 2012-01-10 17:53
    关注

    If I understand correctly, you have a user logged in on your mobile app and you want to access stored data on your server. (Or maybe the other way around, can't really tell from your question).

    Aside from the custom authentication solutions you can use, have you considered passing the facebook access token instead of the id as a simpler solution. The access token expires, it's not public and you can easily exchange it for an id from facebook or parse the token itself. Here is an example solution:

    How to get the Facebook user id using the access token You can also validate the user on the server or client side easily with the token. I haven't used this solution with mobile apps, but have used something similar for multisite apps. Good luck

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

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法