List friends using php

135 views
Skip to first unread message

Lleoun

unread,
Jan 19, 2011, 4:27:28 AM1/19/11
to foursquare API
Hi all,

Using Foursquare V2 Api and php, I'm trying to list my friends.

I need a list like:
http://developer.foursquare.com/docs/explore.html#req=users/self/friends

To do so, I'm following:
http://developer.foursquare.com/docs/users/friends.html

And (I think) I do the authentication correctly, as I reach the Allow
page and if I print $token I get what it seems the right info. But
printing $res shows the same info as printing $token .. Can anyone
give me a hand in here?

The code is below. Thanks a lot!!




<?php


//requires taken from https://github.com/jmathai/foursquare-async
require_once('EpiCurl.php');
require_once('EpiSequence.php');
require_once('EpiFoursquare.php');


$fsObj = new EpiFoursquare($clientId, $clientSecret);
$url = $fsObj->getAuthorizeUrl($redirectUrl);
echo "<a href=\"$url\">Click here</a>";

$thecode = $_GET['code'];

// I insert $thecode in database here

$token = $fsObj->getAccessToken($thecode, $redirectUrl);
$fsObj->setAccessToken($thecode);
$res = $fsObj->get('https://api.foursquare.com/v2/users/',
array('USER_ID' => 'self'));

print_r ($res);
?>

Greg Avola

unread,
Jan 21, 2011, 2:08:38 PM1/21/11
to foursquare API
I think the call you want to make is:

$res = f$fsObj->get("/users/self/friends");

The result should be in:

print_r($res->response);

On Jan 19, 4:27 am, Lleoun <lle...@gmail.com> wrote:
> Hi all,
>
> Using Foursquare V2 Api and php, I'm trying to list my friends.
>
> I need a list like:http://developer.foursquare.com/docs/explore.html#req=users/self/friends
>
> To do so, I'm following:http://developer.foursquare.com/docs/users/friends.html
>
> And (I think) I do the authentication correctly, as I reach the Allow
> page and if I print $token I get what it seems the right info. But
> printing $res shows the same info as printing $token .. Can anyone
> give me a hand in here?
>
> The code is below. Thanks a lot!!
>
>     <?php
>
>     //requires taken fromhttps://github.com/jmathai/foursquare-async
Reply all
Reply to author
Forward
0 new messages