Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/aaronwaldon/twitter-async
Browse files Browse the repository at this point in the history
…into pr-166
  • Loading branch information
jmathai committed May 2, 2013
2 parents 0929f87 + 8c730de commit d5c1cb2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions EpiTwitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ class EpiTwitter extends EpiOAuth
protected $accessTokenUrl = 'https://api.twitter.com/oauth/access_token';
protected $authorizeUrl = 'https://api.twitter.com/oauth/authorize';
protected $authenticateUrl= 'https://api.twitter.com/oauth/authenticate';
protected $apiUrl = 'https://api.twitter.com';
protected $apiUrl = 'http://api.twitter.com';
protected $userAgent = 'EpiTwitter (http://github.com/jmathai/twitter-async/tree/)';
protected $apiVersion = '1.1';
protected $apiVersion = '1';
protected $isAsynchronous = false;
/**
* The Twitter API version 1.0 search URL.
* @var string
*/
protected $searchUrl = 'http://search.twitter.com';

/* OAuth methods */
public function delete($endpoint, $params = null)
Expand Down Expand Up @@ -55,6 +60,11 @@ public function post_basic($endpoint, $params = null, $username = null, $passwor
return $this->request_basic('POST', $endpoint, $params, $username, $password);
}

public function useApiUrl($url = '')
{
$this->apiUrl = rtrim( $url, '/' );
}

public function useApiVersion($version = null)
{
$this->apiVersion = $version;
Expand Down Expand Up @@ -101,7 +111,12 @@ public function __call($name, $params = null/*, $username, $password*/)

private function getApiUrl($endpoint)
{
return "{$this->apiUrl}/{$this->apiVersion}{$endpoint}";
if ($this->apiVersion === '1' && preg_match('@^/search[./]?(?=(json|daily|current|weekly))@', $endpoint))
{
return $this->searchUrl.$endpoint;
}

return $this->apiUrl.'/'.$this->apiVersion.$endpoint;
}

private function request($method, $endpoint, $params = null)
Expand Down

0 comments on commit d5c1cb2

Please sign in to comment.