From: "Ward Morris" on
I've been struggling with integration to Facebook via the PEAR package and
was wondering if anyone has a basic example? I'm past the issues on
installing the package and enabling curl for apache. Currently, I'm getting
'Invalid API Key' back from Facebook, but I've checked and double checked
that the key and secret are correct for my application. In short, all I
want to do is to pull announcements and photos from a Facebook user and
display on an external website.



Here's an excerpt of my code.







// Contains all the includes for application as well as PEAR includes.

include_once '../include_path.php';



try {

$api = new Services_Facebook();

$api->apiKey = '[key]';

$api->secret = '[secret]';

$api->useSessionSecret();

$photos = $api->photos->getPhotosByUser('[uid]');

}

catch (Services_Facebook_Exception $e) {

echo $e->getMessage();

}









Thanks for any help you can offer.



Ward



Ward Morris

email: morris.ward(a)gmail.com <mailto:mmorris.ward(a)gmail.com>

cell: (573) 434-1056



From: Bill Shupp on
On Apr 4, 2010, at 8:56 AM, Ward Morris wrote:

> I've been struggling with integration to Facebook via the PEAR package and
> was wondering if anyone has a basic example? I'm past the issues on
> installing the package and enabling curl for apache. Currently, I'm getting
> 'Invalid API Key' back from Facebook, but I've checked and double checked
> that the key and secret are correct for my application. In short, all I
> want to do is to pull announcements and photos from a Facebook user and
> display on an external website.
>
>
>
> Here's an excerpt of my code.
>
>
> // Contains all the includes for application as well as PEAR includes.
>
> include_once '../include_path.php';
>
>
>
> try {
>
> $api = new Services_Facebook();
>
> $api->apiKey = '[key]';
>
> $api->secret = '[secret]';
>
> $api->useSessionSecret();
>
> $photos = $api->photos->getPhotosByUser('[uid]');
>
> }
>
> catch (Services_Facebook_Exception $e) {
>
> echo $e->getMessage();
>
> }

You're not using static variables (we need to fix this). Also, I don't think you need the "useSessionSecret()" setting. Try this:

try {

Services_Facebook::$apiKey = 'apikey';
Services_Facebook::$secret = 'secret';
Services_Facebook::$sessionKey = 'session_key';

$api = new Services_Facebook();

$photos = $api->photos->getPhotosByUser('user_id');
var_dump($photos);

}

catch (Services_Facebook_Exception $e) {

echo $e->getMessage();

}

From: Bill Shupp on
On Apr 4, 2010, at 9:33 AM, Ward Morris wrote:

> Bill, thanks for your direction; Looks like I'm on a better path now. I'm
> semi-confused with the session key, because all the documentation I can find
> assumes the application already has a session key. I assume that I need to
> create a new key; is this considered a Facebook session id or simply the
> current php session id?
>
> Thanks for your help.
>
> Ward

When the user authorizes or logs into your application, you need to store the session key so that you can use it here. See http://wiki.developers.facebook.com/index.php/API#Login.2FAuth_Methods for more details.

Regards,

Bill
From: Bill Shupp on
On Apr 4, 2010, at 9:43 AM, Ward Morris wrote:

> Also, I just noticed that from 0.2.14, sessionKey isn't declared as static.

Yeah, they will all become non-static in the future. It's kind of a mess right now, sorry for the confusion.

Regards,

Bill
From: "Ward Morris" on
The difference with my site is that I don't care who is coming to the site
or whether they've logged in to Facebook. I want to use an application
defined Facebook user and pull announcement, messages, photos from other
Facebook users (of course my application defined Facebook user would have
access to view that info on the other users accounts). I'm going in circles
reading articles and docs on Facebook Connect, because I don't want my users
to have to login.

In short, I want to create website for a customer who has a Facebook
account. On this customer's website, I want to pull content from its
Facebook account.

Any ideas?

-----Original Message-----
From: Bill Shupp [mailto:hostmaster(a)shupp.org]
Sent: Sunday, April 04, 2010 11:48 AM
To: PEAR general mailing list
Cc: Ward Morris
Subject: Re: [PEAR] Services/Facebook Examples

On Apr 4, 2010, at 9:33 AM, Ward Morris wrote:

> Bill, thanks for your direction; Looks like I'm on a better path now. I'm
> semi-confused with the session key, because all the documentation I can
find
> assumes the application already has a session key. I assume that I need
to
> create a new key; is this considered a Facebook session id or simply the
> current php session id?
>
> Thanks for your help.
>
> Ward

When the user authorizes or logs into your application, you need to store
the session key so that you can use it here. See
http://wiki.developers.facebook.com/index.php/API#Login.2FAuth_Methods for
more details.

Regards,

Bill=