Yii Framework Forum: Yii with facebook question - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii with facebook question Rate Topic: -----

#1 User is offline   terryxiang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-April 10

Posted 13 April 2010 - 06:43 AM

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.
0

#2 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 07:05 AM

The problem is probably because facebook class is trying to include other class files. You should check out this guide page: http://www.yiiframew...ion.integration to see how to implement third party libraries into Yii.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#3 User is offline   terryxiang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-April 10

Posted 13 April 2010 - 08:12 AM

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 )
0

#4 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 08:40 AM

Yes, That's what the guide says to do. ;)
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#5 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 15 April 2010 - 10:58 PM

View Postterryxiang, on 13 April 2010 - 08:12 AM, said:

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...
0

#6 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 16 April 2010 - 01:20 AM

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.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#7 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 16 April 2010 - 06:48 AM

Weird it worked for me without.. but maybe because I tested on windows case insensitive...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users