8000 Add support for old API v1 methods · robholmes/codebird-php@e96284a · GitHub
[go: up one dir, main page]

Skip to content

Commit e96284a

Browse files
committed
Add support for old API v1 methods
1 parent 462ee4b commit e96284a

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

codebird.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class Codebird
6565
*/
6666
private $_endpoint_oauth = 'https://api.twitter.com/';
6767

68+
/**
69+
* The API endpoint to use for untransitioned methods
70+
*/
71+
private $_endpoint_old = 'https://api.twitter.com/1/';
72+
6873
/**
6974
* The API endpoint to use for internal requests
7075
*/
@@ -477,6 +482,7 @@ private function _detectMethod($method, $params)
477482
'users/search',
478483
'users/contributees',
479484
'users/contributors',
485+
'users/recommendations',
480486

481487
// Suggested Users
482488
'users/suggestions/:slug',
@@ -527,10 +533,11 @@ private function _detectMethod($method, $params)
527533
'activity/about_me',
528534
'activity/by_friends',
529535
'search/typeahead',
530-
'statuses/:id/activity/summary'
531-
// Not authorized as of 2012-10-17
532-
// 'discovery',
533-
// 'resolve'
536+
'statuses/:id/activity/summary',
537+
538+
// Not authorized as of 2012-10-17
539+
'discovery',
540+
'resolve'
534541
);
535542
$httpmethods['POST'] = array(
536543
// Tweets
@@ -555,9 +562,8 @@ private function _detectMethod($method, $params)
555562
'account/update_profile_background_image',
556563
'account/update_profile_colors',
557564
'account/update_profile_image',
558-
// not supported in 1.1 as of 2012-10-17
559-
// 'account/update_profile_banner',
560-
// 'account/remove_profile_banner',
565+
'account/update_profile_banner',
566+
'account/remove_profile_banner',
561567
'blocks/create',
562568
'blocks/destroy',
563569

@@ -619,6 +625,24 @@ private function _detectMultipart($method)
619625
return in_array($method, $multiparts);
620626
}
621627

628+
/**
629+
* Detects if API call should use the old endpoint
630+
*
631+
* @param string $method The API method to call
632+
*
633+
* @return bool Whether the method is defined in old API
634+
*/
635+
private function _detectOld($method)
636+
{
637+
$olds = array(
638+
// Users
639+
'account/update_profile_banner',
640+
'account/remove_profile_banner',
641+
'users/recommendations'
642+
);
643+
return in_array($method, $olds);
644+
}
645+
622646
/**
623647
* Detects if API call should use internal endpoint
624648
*
@@ -720,6 +744,8 @@ private function _getEndpoint($method, $method_template)
720744
{
721745
if (substr($method, 0, 6) == 'oauth/') {
722746
$url = $this->_endpoint_oauth . $method;
747+
} elseif ($this->_detectOld($method_template)) {
748+
$url = $this->_endpoint_old . $method . '.json';
723749
} elseif ($this->_detectInternal($method_template)) {
724750
$url = $this->_endpoint_internal . $method . '.json';
725751
} else {

0 commit comments

Comments
 (0)
0