如何导入facebook php sdk v4在cakephp 2.4。 [英] How to import the facebook php sdk v4 in cakephp 2.4.?

查看:132
本文介绍了如何导入facebook php sdk v4在cakephp 2.4。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试导入和使用我的AppController中的facebook php sdk的FacebookRedirectLoginHelper类,但获得类'FacebookRedirectLoginHelper'未找到异常。

Trying to import and use the FacebookRedirectLoginHelper class of the facebook php sdk in my AppController but getting a Class 'FacebookRedirectLoginHelper' not found Exception.

App::import('Vendor', 'facebook', array('file' => 'facebook-php-sdk-v4-master' . DS . 'src' . DS . 'Facebook' . DS . 'FacebookRedirectLoginHelper.php'));

$helper = new FacebookRedirectLoginHelper($redirect_url, 'xxxx', 'yyyyy'); 

任何想法?提前感谢

推荐答案

我有同样的问题,尝试了大部分的解决方案。最后没有什么工作,因为我指向错误的构建,我没有告诉CakePHP使用Composer自动加载器。

I had the same issue and tried most of the solutions here. In the end nothing worked because I was point to the wrong build and I was not telling CakePHP to use the Composer Autoloader.

在我的composer.json我改变:
facebook / php-sdk-v4:dev-master
to
facebook / php- sdk-v4:4.0。*
并在我的 Config / bootstrap.php p>

In my composer.json I changed: "facebook/php-sdk-v4": "dev-master" to "facebook/php-sdk-v4" : "4.0.*" and at the top of my Config/bootstrap.php file I added

<?php
// Load Composer autoload.
require APP . 'Vendor/autoload.php';

// Remove and re-prepend CakePHP's autoloader as Composer thinks it is the
// most important.
// See: http://goo.gl/kKVJO7
spl_autoload_unregister(array('App', 'load'));
spl_autoload_register(array('App', 'load'), true, true);

正确的作曲者条目位于此处: https://developers.facebook.com/docs/php/gettingstarted/4.0.0

The proper composer entry was found here: https://developers.facebook.com/docs/php/gettingstarted/4.0.0

在这里找到了带有CakePHP的作曲家autoloder: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#installing-cakephp-with-composer

The composer autoloder with CakePHP was found here: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#installing-cakephp-with-composer

现在从我应用程式的任何位置,我都可以这样做:

Now from anywhere in my app I can do this:

<?php
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

FacebookSession::setDefaultApplication('app_id', 'app_secret');

希望它有帮助,这个问题不会阻止你继续使用Composer。

Hope it helps and that this issue does not deter you from continuing to use Composer.

这篇关于如何导入facebook php sdk v4在cakephp 2.4。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆