时间:2011-01-06 16:19:44

标签: php

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

如果$facebook->api_client不是对象,则行:

 $facebook->api_client->session_key = FB_SESSION;

将使php静默地将$facebook->api_client强制转换为stdClass类型的对象。其后,在代码之后,将导致您获得的Fatal error: Call to undefined method stdClass::stream_publish()

尝试更改:      ...

 $facebook = new Facebook(FB_APIKEY, FB_SECRET);
 $facebook->api_client->session_key = FB_SESSION;
 $facebook->api_client->expires = 0;

 ...

在api_client为false(或者可能不是对象)时捕获:

 ...

 $facebook = new Facebook(FB_APIKEY, FB_SECRET);

 if (!( $facebook->api_client )) {
   //throw error 
   echo 'Need to sort this bit out';
   exit;
 }   

 $facebook->api_client->session_key = FB_SESSION;
 $facebook->api_client->expires = 0;

 ...

然后,如果确实发生错误,您需要调查$facebook->api_client为空的原因。