Re: Services/Facebook Examples

From: Date: Sun, 04 Apr 2010 16:21:59 +0000
Subject: Re: Services/Facebook Examples
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30438@lists.php.net to get a copy of this message
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(); }

« previous php.pear.general (#30438) next »