且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用facebook php-sdk(v.3.0.0)结合使用会话和cookie的facebook登录

更新时间:2023-11-28 11:16:34

回答您的问题

1)饼干呢?

您只需在Facebook初始化中添加一个参数即可. 将其更改为以下

You just add a parameter to the Facebook initialization. Change it to the following

$facebook = new Facebook(array(
  'appId'  => '...',
  'secret' => '...',
  'cookie' => true,
));

2)我需要从这个example.php文件中找到的最低要求是什么?

2)What is the bare minimum I need to get out of this example.php file to ....

在此示例中,并非您想要的所有内容.代码的上半部分显示了如何连接和验证用户.后半部分仅转储其基本详细信息和naitik的详细信息.对于其余部分,您需要进一步研究.

Not everything you want is in this example. The top half of the code shows you how to connect and validate a user. The second half just dumps out their basic details and naitik's details. For the rest you need to look further.

3)在src/文件中,有一个文件fb_ca_chain_bundle.crt",

3)In the src/ files, there is one 'file fb_ca_chain_bundle.crt,'

此文件的目的是为CURL错误60提供一种解决方法.请阅读以下内容:

The purpose of this file is to offer a workaround for CURL error 60. Read this:

http://www.takwing.idv.hk/blog/2011/php-sdk-demystified-%E2%80%93-how-curl-error-60-is-handled/

4)$ naitik行= $ facebook-> api('/naitik');是"naitik"这个人的用户名-因此,如果我输入facebook.com/naitik,它将显示他的公开个人资料?将"/naitik"替换为"/me",将获得登录Facebook的人的公开个人资料?

4)The line $naitik = $facebook->api('/naitik'); is "naitik" the username of this person--so if I type facebook.com/naitik it will show his public profile? is replacing "/naitik" with "/me" what will get the public profile of the person logged into facebook?

完全正确

5)如何获取访问令牌,以及如何在代码中使用它?

5)How do I get the access token, and how do I use it in my code?

$ facebook-> getAccessToken();

$facebook->getAccessToken();

您在其中添加了一些方法调用,但这并不是所有操作都必需的.

You add it some of the method calls, but it is not necessary for everything.

6)当我为用户创建会话和cookie以便重新打开浏览器后登录用户时,会话和cookie中应该确切存储什么?

6)When I create a session for the user, and a cookie so that the user is logged in after reopening the browser, what should I exactly be storing in my sessions and cookies?

Facebook SDk将解决此问题.您只需要存储有关您的App所需用户的任何其他信息.

The Facebook SDk is going to take care of that. You will just need to store whatever extra information about the user your App requires.