Skip to content

Commit

Permalink
Adding support for unauthenticated calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmathai committed Jan 21, 2011
1 parent c7da3f8 commit 2d077ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion EpiFoursquare.php
Expand Up @@ -92,15 +92,22 @@ private function getApiUrl($endpoint)
return "{$this->apiUrl}{$endpoint}";
}

private function request($method, $endpoint, $params = null, $username = null, $password = null)
private function request($method, $endpoint, $params = null)
{
if(preg_match('#^https?://#', $endpoint))
$url = $endpoint;
else
$url = $this->getApiUrl($endpoint);

if($this->accessToken)
{
$params['oauth_token'] = $this->accessToken;
}
else
{
$params['client_id'] = $this->clientId;
$params['client_secret'] = $this->clientSecret;
}

if($method === 'GET')
$url .= is_null($params) ? '' : '?'.http_build_query($params, '', '&');
Expand Down
6 changes: 6 additions & 0 deletions simpleTest.php
Expand Up @@ -22,6 +22,12 @@

<hr>

<h2>Test an unauthenticated call to search for a venue</h2>
<?php $venue = $fsObjUnAuth->get('/venues/search', array('ll' => '40.7,-74')); ?>
<pre><?php var_dump($venue->response->response->groups->items[0]); ?></pre>

<hr>

<?php if(!isset($_GET['code']) && !isset($_COOKIE['access_token'])) { ?>
<h2>Generate the authorization link</h2>
<?php $authorizeUrl = $fsObjUnAuth->getAuthorizeUrl($redirectUri); ?>
Expand Down

0 comments on commit 2d077ce

Please sign in to comment.