@@ -65,6 +65,11 @@ class Codebird
65
65
*/
66
66
private $ _endpoint_oauth = 'https://api.twitter.com/ ' ;
67
67
68
+ /**
69
+ * The API endpoint to use for untransitioned methods
70
+ */
71
+ private $ _endpoint_old = 'https://api.twitter.com/1/ ' ;
72
+
68
73
/**
69
74
* The API endpoint to use for internal requests
70
75
*/
@@ -477,6 +482,7 @@ private function _detectMethod($method, $params)
477
482
'users/search ' ,
478
483
'users/contributees ' ,
479
484
'users/contributors ' ,
485
+ 'users/recommendations ' ,
480
486
481
487
// Suggested Users
482
488
'users/suggestions/:slug ' ,
@@ -527,10 +533,11 @@ private function _detectMethod($method, $params)
527
533
'activity/about_me ' ,
528
534
'activity/by_friends ' ,
529
535
'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 '
534
541
);
535
542
$ httpmethods ['POST ' ] = array (
536
543
// Tweets
@@ -555,9 +562,8 @@ private function _detectMethod($method, $params)
555
562
'account/update_profile_background_image ' ,
556
563
'account/update_profile_colors ' ,
557
564
'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 ' ,
561
567
'blocks/create ' ,
562
568
'blocks/destroy ' ,
563
569
@@ -619,6 +625,24 @@ private function _detectMultipart($method)
619
625
return in_array ($ method , $ multiparts );
620
626
}
621
627
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
+
622
646
/**
623
647
* Detects if API call should use internal endpoint
624
648
*
@@ -720,6 +744,8 @@ private function _getEndpoint($method, $method_template)
720
744
{
721
745
if (substr ($ method , 0 , 6 ) == 'oauth/ ' ) {
722
746
$ url = $ this ->_endpoint_oauth . $ method ;
747
+ } elseif ($ this ->_detectOld ($ method_template )) {
748
+ $ url = $ this ->_endpoint_old . $ method . '.json ' ;
723
749
} elseif ($ this ->_detectInternal ($ method_template )) {
724
750
$ url = $ this ->_endpoint_internal . $ method . '.json ' ;
725
751
} else {
0 commit comments