Skip to content

Commit

Permalink
Allowing user agent to be overridden and actually using it in the req…
Browse files Browse the repository at this point in the history
…uest.

Closes jmathaigh-12
  • Loading branch information
jmathai committed Feb 25, 2011
1 parent 5ef22ea commit f0801e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions EpiFoursquare.php
Expand Up @@ -51,6 +51,11 @@ public function setTimeout($requestTimeout = null, $connectionTimeout = null)
$this->connectionTimeout = floatval($connectionTimeout);
}

public function setUserAgent($agent)
{
$this->userAgent = $agent;
}

public function useApiVersion($version = null)
{
$this->apiVersion = $version;
Expand Down Expand Up @@ -112,6 +117,7 @@ private function request($method, $endpoint, $params = null)
if($method === 'GET')
$url .= is_null($params) ? '' : '?'.http_build_query($params, '', '&');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
Expand Down

0 comments on commit f0801e0

Please sign in to comment.