xqterry
(Xqterry)
April 13, 2010, 11:43am
1
Hi
I can not let Yii v1.1.1 r1907 work with facebook api.
OS: opensolaris
PHP: 5.2.12
FB api: latest
I created a simple webapp, and here is source.
$yii=dirname(__FILE__).'/../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
Yii::createWebApplication($config);
Yii::app()->cache->useMemcached = true;
require_once( dirname(__FILE__) . "/protected/components/facebook-platform/php/facebook.php");
$appapikey = 'key';
$appsecret = 'secret';
$facebook = new Facebook($appapikey, $appsecret);
print $facebook->get_loggedin_user();
?>
Then I got:
include(PEAR_Error.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
I searched in forum, someone said php 5.2 has no such issue, I am confuse.
Any suggestions will be appreciated.
Vince
(Vadimg88)
April 13, 2010, 12:05pm
2
The problem is probably because facebook class is trying to include other class files. You should check out this guide page: http://www.yiiframework.com/doc/guide/extension.integration to see how to implement third party libraries into Yii.
xqterry
(Xqterry)
April 13, 2010, 1:12pm
3
Hi Vince
Thank you, it works.
what I did is:
Yii::import('application.vendors.facebook-platform.*');
spl_autoload_unregister(array('YiiBase','autoload'));
require_once('php/Facebook.php');
spl_autoload_register(array('YiiBase','autoload'));
( I renamed facebook.php to Facebook.php )
Vince
(Vadimg88)
April 13, 2010, 1:40pm
4
Yes, That’s what the guide says to do.
mech7
(Chris De Kok)
April 16, 2010, 3:58am
5
Hi Vince
Thank you, it works.
what I did is:
Yii::import('application.vendors.facebook-platform.*');
spl_autoload_unregister(array('YiiBase','autoload'));
require_once('php/Facebook.php');
spl_autoload_register(array('YiiBase','autoload'));
( I renamed facebook.php to Facebook.php )
You should not have to register a new autoload…
Vince
(Vadimg88)
April 16, 2010, 6:20am
6
His not, He just unregisters the Yii autoload to successfully include the facebook api classes. And the above code is what the guide says to in this kind of situations.
mech7
(Chris De Kok)
April 16, 2010, 11:48am
7
Weird it worked for me without… but maybe because I tested on windows case insensitive…