问题描述
我很难用Facebook的SDK文档。我从Github下载了SDK,并将其添加到我的PHP项目中。这是文件系统:
├──Facebook
│├──FacebookAuthorizationException.php
│├──FacebookCanvasLoginHelper.php
│├──FacebookClientException.php
│├──FacebookJavaScriptLoginHelper.php
│├──FacebookOtherException.php
│├──FacebookPermissionException.php
│├──FacebookRedirectLoginHelper.php
│├──FacebookRequest。 php
│├──FacebookRequestException.php
│├──FacebookResponse.php
│├──FacebookSDKException.php
│├──FacebookServerException.php
│ ├──FacebookSession.php
│├──FacebookThrottleException.php
│├──GraphLocation.php
│├──GraphObject.php
│├──GraphSessionInfo.php
│├──GraphUser.php
│└──fb_ca_chain_bundle.crt
└──test.php
这是我的代码到目前为止:
使用Facebook\FacebookSession;
使用Facebook\FacebookRequest;
使用Facebook\GraphUser;
使用Facebook\FacebookRequestException;
FacebookSession :: setDefaultApplication('*******','******');
$ helper = new FacebookRedirectLoginHelper('http://isgeek.eu/fb/FaRepost/return.php');
$ loginUrl = $ helper-> getLoginUrl();
//使用链接或按钮上的登录URL重定向到Facebook进行身份验证
我收到这个错误
致命错误:类Facebook\FacebookSession未找到/ homeepages / 2 / d184071366 / htdocs / isgeek / fb / FaRepost / test.php第9行
更新了我的PHP版本,所以问题不从这里来。似乎没有找到PHP文件。我看到这个问题(),但是没有帮助。
这个comme从哪里来?
我发现解决方案
我没有在php中编写一段时间,事情已经改变了。 使用Facebook\FacebookSession;
是不够的。您还需要添加 require_once
。
require_once('Facebook / FacebookSession.php');
编辑:有关更详细的解决方案,请查看以下答案。
I am having a hard time with facebook's SDK documentation. I downloaded the SDK from Github and added it into my PHP project.
Here is the file system:
├── Facebook
│ ├── FacebookAuthorizationException.php
│ ├── FacebookCanvasLoginHelper.php
│ ├── FacebookClientException.php
│ ├── FacebookJavaScriptLoginHelper.php
│ ├── FacebookOtherException.php
│ ├── FacebookPermissionException.php
│ ├── FacebookRedirectLoginHelper.php
│ ├── FacebookRequest.php
│ ├── FacebookRequestException.php
│ ├── FacebookResponse.php
│ ├── FacebookSDKException.php
│ ├── FacebookServerException.php
│ ├── FacebookSession.php
│ ├── FacebookThrottleException.php
│ ├── GraphLocation.php
│ ├── GraphObject.php
│ ├── GraphSessionInfo.php
│ ├── GraphUser.php
│ └── fb_ca_chain_bundle.crt
└── test.php
here is my code so far:
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
FacebookSession::setDefaultApplication('*******','******');
$helper = new FacebookRedirectLoginHelper('http://isgeek.eu/fb/FaRepost/return.php');
$loginUrl = $helper->getLoginUrl();
// Use the login url on a link or button to redirect to Facebook for authentication
I get this error
Fatal error: Class 'Facebook\FacebookSession' not found in /homepages/2/d184071366/htdocs/isgeek/fb/FaRepost/test.php on line 9
At updated my PHP version, so the issue does not comme from here. It seems like the PHP files are not found. I read this question (Facebook SDK v4 for PHP Minimal Example) but it does not help.
Where does this comme from?
I found the solution here
I did not code in php for some time now and things have changed. use Facebook\FacebookSession;
is not enough. You need to add a require_once
too.
require_once( 'Facebook/FacebookSession.php' );
Edit: for a more detailed solution, please checkout the answer below.
这篇关于错误:使用Facebook PHP SDK找不到类“Facebook\FacebookSession”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!