Facebook连接脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Facebook连接脚本相关的知识,希望对你有一定的参考价值。

default facebook connect script
  1. <?php
  2.  
  3. require 'src/facebook.php'; // download from github facebook php sdk
  4.  
  5. // Create our Application instance (replace this with your appId and secret).
  6. $facebook = new Facebook(array(
  7. 'appId' => 'YOUR_APP_ID',
  8. 'secret' => 'YOU_SECRET_KEY',
  9. 'cookie' => true,
  10. ));
  11.  
  12. // We may or may not have this data based on a $_GET or $_COOKIE based session.
  13. //
  14. // If we get a session here, it means we found a correctly signed session using
  15. // the Application Secret only Facebook and the Application know. We dont know
  16. // if it is still valid until we make an API call using the session. A session
  17. // can become invalid if it has already expired (should not be getting the
  18. // session back in this case) or if the user logged out of Facebook.
  19. $session = $facebook->getSession();
  20.  
  21. $fbinfo = null;
  22. // Session based API call.
  23. if ($session) {
  24. try {
  25. $fbid = $facebook->getUser();
  26. $fbinfo = $facebook->api('/me');
  27. //print_r($fbinfo);
  28. } catch (FacebookApiException $e) {
  29. error_log($e);
  30. }
  31. }
  32.  
  33. ?>

以上是关于Facebook连接脚本的主要内容,如果未能解决你的问题,请参考以下文章

iOS)我应该在哪里复制和粘贴 facebook XML 片段?

Android Studio 中的 Facebook SDK 4 ExceptionInitializeError Login v2.3

PHP中的Facebook Graph API出现不一致的错误 - 无法连接到graph.facebook.com端口443:连接超时

Facebook 喜欢和评论代码脚本

常用python日期日志获取内容循环的代码片段

有人知道下面的代码片段是啥意思吗?