8000 Add new methods now available in 1.1 · codezninja/codebird-php@040ca36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 040ca36

Browse files
committed
Add new methods now available in 1.1
1 parent fe8fe75 commit 040ca36

File tree

1 file changed

+7
-51
lines changed

1 file changed

+7
-51
lines changed

codebird.php

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ class Codebird
7070
*/
7171
private $_endpoint_old = 'https://api.twitter.com/1/';
7272

73-
/**
74-
* The API endpoint to use for internal requests
75-
*/
76-
private $_endpoint_internal = 'https://api.twitter.com/i/';
77-
7873
/**
7974
* The Request or access token. Used to sign requests
8075
*/
@@ -103,7 +98,7 @@ class Codebird
10398
/**
10499
* The current Codebird version
105100
*/
106-
private $_version = '2.2.2-internal';
101+
private $_version = '2.2.3';
107102

108103
/**
109104
* Returns singleton class instance
@@ -240,12 +235,11 @@ public function __call($fn, $params)
240235

241236
$httpmethod = $this->_detectMethod($method_template, $apiparams);
242237
$multipart = $this->_detectMultipart($method_template);
243-
$internal = $this->_detectInternal($method_template);
244238

245239
// geek-geek: Now allowing to specify filenames as params
246240
$this->_detectFilenames($method_template, $apiparams);
247241

248-
return $this->_callApi($httpmethod, $method, $method_template, $apiparams, $multipart, $internal);
242+
return $this->_callApi($httpmethod, $method, $method_template, $apiparams, $multipart);
249243
}
250244

251245
/**
@@ -451,6 +445,7 @@ private function _detectMethod($method, $params)
451445
'statuses/mentions_timeline',
452446
'statuses/user_timeline',
453447
'statuses/home_timeline',
448+
'statuses/retweets_of_me',
454449

455450
// Tweets
456451
'statuses/retweets/:id',
@@ -484,6 +479,7 @@ private function _detectMethod($method, $params)
484479
'users/contributees',
485480
'users/contributors',
486481
'users/recommendations',
482+
'users/profile_banner',
487483

488484
// Suggested Users
489485
'users/suggestions/:slug',
@@ -528,17 +524,7 @@ private function _detectMethod($method, $params)
528524
'help/languages',
529525
'help/privacy',
530526
'help/tos',
531-
'application/rate_limit_status',
532-
533-
// Internal
534-
'activity/about_me',
535-
'activity/by_friends',
536-
'search/typeahead',
537-
'statuses/:id/activity/summary',
538-
539-
// Not authorized as of 2012-10-17
540-
'discovery',
541-
'resolve'
527+
'application/rate_limit_status'
542528
);
543529
$httpmethods['POST'] = array(
544530
// Tweets
@@ -563,8 +549,8 @@ private function _detectMethod($method, $params)
563549
'account/update_profile_background_image',
564550
'account/update_profile_colors',
565551
'account/update_profile_image',
566-
'account/update_profile_banner',
567552
'account/remove_profile_banner',
553+
'account/update_profile_banner',
568554
'blocks/create',
569555
'blocks/destroy',
570556

@@ -637,34 +623,11 @@ private function _detectOld($method)
637623
{
638624
$olds = array(
639625
// Users
640-
'account/update_profile_banner',
641-
'account/remove_profile_banner',
642626
'users/recommendations'
643627
);
644628
return in_array($method, $olds);
645629
}
646630

647-
/**
648-
* Detects if API call should use internal endpoint
649-
*
650-
* @param string $method The API method to call
651-
*
652-
* @return bool Whether the method is defined in internal API
653-
*/
654-
private function _detectInternal($method)
655-
{
656-
$internals = array(
657-
// Activity
658-
'activity/about_me',
659-
'activity/by_friends',
660-
'discovery',
661-
'search/typeahead',
662-
'statuses/:id/activity/summary',
663-
'resolve'
664-
);
665-
return in_array($method, $internals);
666-
}
667-
668631
/**
669632
* Detects filenames in upload parameters
670633
*
@@ -747,8 +710,6 @@ private function _getEndpoint($method, $method_template)
747710
$url = $this->_endpoint_oauth . $method;
748711
} elseif ($this->_detectOld($method_template)) {
749712
$url = $this->_endpoint_old . $method . '.json';
750-
} elseif ($this->_detectInternal($method_template)) {
751-
$url = $this->_endpoint_internal . $method . '.json';
752713
} else {
753714
$url = $this->_endpoint . $method . '.json';
754715
}
@@ -763,20 +724,15 @@ private function _getEndpoint($method, $method_template)
763724
* @param string $method_template The templated API method to call
764725
* @param array optional $params The parameters to send along
765726
* @param bool optional $multipart Whether to use multipart/form-data
766-
* @param bool optional $internal Whether to use internal API
767727
*
768728
* @return mixed The API reply, encoded in the set return_format
769729
*/
770730

771-
private function _callApi($httpmethod, $method, $method_template, $params = array(), $multipart = false, $internal = false)
731+
private function _callApi($httpmethod, $method, $method_template, $params = array(), $multipart = false)
772732
{
773733
if (! function_exists('curl_init')) {
774734
throw new Exception('To make API requests, the PHP curl extension must be available.');
775735
}
776-
if ($internal) {
777-
$params['adc'] = 'phone';
778-
$params['application_id'] = 333903271;
779-
}
780736
$url = $this->_getEndpoint($method, $method_template);
781737
$ch = false;
782738
if ($httpmethod == 'GET') {

0 commit comments

Comments
 (0)
0