views:

174

answers:

2

I've been working at this for a few hours, but the poor documentation is of no help.

All I want to do is grab the data that exists at https://graph.facebook.com/cocacola/ as an example, and I cant even do that.

I'm using the latest php API from facebook.

This is my code, which returns nothing:

<?php

require '../src/facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => '254752073152',
  'secret' => '904270b68a2cc3d54485323652da4d14',
  'cookie' => true,
));


$coke = $facebook->api('/cocacola');


echo '<pre>';
print_r($coke);
echo '</pre>';

Any idea?

A: 

Sorry I can't comment, but that doesn't look like a valid API key (not long enough). The 'appId' should be your API key not your Application ID.

joslinm
No, the new facebook PHP API requires your Application ID, not your API Key. See the documentation: <?phprequire './facebook.php';$facebook = new Facebook(array( 'appId' => 'YOUR APP ID', 'secret' => 'YOUR API SECRET', 'cookie' => true, // enable optional cookie support));
Wes
Not true.. look at the facebook constructor: `/** * Initialize a Facebook Application. * * The configuration: * - appId: the application API key * - secret: the application secret * - cookie: (optional) boolean true to enable cookie support * - domain: (optional) domain for the cookie * * @param Array $config the application configuration */ public function __construct($config) {`I have no idea why they would start calling it appID.. confusing I know.(Sorry, that's hard to read, see it here: http://github.com/facebook/php-sdk/blob/master/src/facebook.php)
joslinm
I figured it out, no help from the the documentation. I needed to call both the API key and the APP ID. Thanks :)
Wes
where did you call the app id?
fuz3d
+1  A: 

Checkout the tutorial http://thinkdiff.net/facebook/php-sdk-graph-api-base-facebook-connect-tutorial/ to fully understand step by step of graph api and php sdk.

Mahmud Ahsan
thats actually where I ended up getting code that works haha. No help from facebook :|
Wes