How to get the stream of a public Facebook fanpage in php? -


i want display public fanpage feed onto website via facebook api without requiring login.

i'm doing this

require_once('../includes/classes/facebook-platform/php/facebook.php');  $fb = new facebook($api_key, $secret); $fb->api_client->stream_get('',$app_id,'0','0','','','','','')); 

but error

 fatal error:  uncaught exception 'facebookrestclientexception' message 'user id parameter or session key required' in includes/classes/facebook-platform/php/facebookapi_php5_restlib.php:3065  stack trace: #0 includes/classes/facebook-platform/php/facebookapi_php5_restlib.php(1915): facebookrestclient->call_method('facebook.stream...', array) #1 facebook/api.php(12): facebookrestclient->stream_get('', 13156929019, '0', '0', 30, '', '', '', '') #2 {main}   thrown in includes/classes/facebook-platform/php/facebookapi_php5_restlib.php on line 3065 

then figured, because of 'user id parameter or session key required', add user id call

require_once('../includes/classes/facebook-platform/php/facebook.php');  $fb = new facebook($api_key, $secret); $fb->api_client->stream_get(502945616,13156929019,$app_id,'0','0','','','','','')); 

but got error

fatal error:  uncaught exception 'facebookrestclientexception' message 'session key invalid or no longer valid' 

i'm totally clueless :)

here's did

1) login facebook.

2) grant application offline access account: http://m.facebook.com/authorize.php?api_key=your_api_key&v=1.0&ext_perm=offline_access

3) add read stream permission http://m.facebook.com/authorize.php?api_key=your_api_key&v=1.0&ext_perm=read_stream

4) generate key code http://www.facebook.com/code_gen.php?v=1.0&api_key=your_api_key

5) run script once , copy "session_key".

$facebook = new facebook($api_key, $api_secret); $infinite_key = $facebook->api_client->auth_getsession(your_key_code); print_r($infinite_key); 

6) plug , play!

$facebook->api_client->user = your_facebook_user_id $facebook->api_client->session_key = your_infinite_key $facebook->api_client->expires = 0; $feed = $facebook->api_client->stream_get(your_facebook_user_id, fan_page_id); 

so bascially, grab feed "perspective" filter show items specified fan page.

disclaimer: works, i'm not sure whether "supported" method grabbing data, or allowed @ all.

references:

http://www.emcro.com/blog/2009/01/facebook-infinite-session-keys-no-more/

http://blog.jylin.com/2009/10/01/loading-wall-posts-using-facebookstream_get/


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -