8000 Finish 42-get-post-getter · devildeveloper/codebird-php@425d9c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 425d9c9

Browse files
committed
Finish 42-get-post-getter
2 parents 22f6356 + eae1161 commit 425d9c9

File tree

2 files changed

+163
-149
lines changed

2 files changed

+163
-149
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ codebird-php - changelog
44
2.5.0 (not yet released)
55
+ Add section about cacert.pem to README
66
+ Option to set cURL timeout
7+
+ #42 Allow to get the supported API methods as array
78

89
2.4.1 (2013-06-23)
910
+ #26 Stringify null and boolean parameters

src/cod 8000 ebird.php

Lines changed: 162 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,166 @@ public function setReturnFormat($return_format)
221221
$this->_return_format = $return_format;
222222
}
223223

224+
/**
225+
* Get allowed API methods, sorted by GET or POST
226+
* Watch out for multiple-method "account/settings"!
227+
*
228+
* @return array $apimethods
229+
*/
230+
function getApiMethods()
231+
{
232+
static $apimethods = array(
233+
'GET' => array(
234+
// Timelines
235+
'statuses/mentions_timeline',
236+
'statuses/user_timeline',
237+
'statuses/home_timeline',
238+
'statuses/retweets_of_me',
239+
240+
// Tweets
241+
'statuses/retweets/:id',
242+
'statuses/show/:id',
243+
'statuses/oembed',
244+
245+
// Search
246+
'search/tweets',
247+
248+
// Direct Messages
249+
'direct_messages',
250+
'direct_messages/sent',
251+
'direct_messages/show',
252+
253+
// Friends & Followers
254+
'friendships/no_retweets/ids',
255+
'friends/ids',
256+
'followers/ids',
257+
'friendships/lookup',
258+
'friendships/incoming',
259+
'friendships/outgoing',
260+
'friendships/show',
261+
'friends/list',
262+
'followers/list',
263+
264+
// Users
265+
'account/settings',
266+
'account/verify_credentials',
267+
'blocks/list',
268+
'blocks/ids',
269+
'users/lookup',
270+
'users/show',
271+
'users/search',
272+
'users/contributees',
273+
'users/contributors',
274+
'users/profile_banner',
275+
276+
// Suggested Users
277+
'users/suggestions/:slug',
278+
'users/suggestions',
279+
'users/suggestions/:slug/members',
280+
281+
// Favorites
282+
'favorites/list',
283+
284+
// Lists
285+
'lists/list',
286+
'lists/statuses',
287+
'lists/memberships',
288+
'lists/subscribers',
289+
'lists/subscribers/show',
290+
'lists/members/show',
291+
'lists/members',
292+
'lists/show',
293+
'lists/subscriptions',
294+
295+
// Saved searches
296+
'saved_searches/list',
297+
'saved_searches/show/:id',
298+
299+
// Places & Geo
300+
'geo/id/:place_id',
301+
'geo/reverse_geocode',
302+
'geo/search',
303+
'geo/similar_places',
304+
305+
// Trends
306+
'trends/place',
307+
'trends/available',
308+
'trends/closest',
309+
310+
// OAuth
311+
'oauth/authenticate',
312+
'oauth/authorize',
313+
314+
// Help
315+
'help/configuration',
316+
'help/languages',
317+
'help/privacy',
318+
'help/tos',
319+
'application/rate_limit_status'
320+
),
321+
'POST' => array(
322+
// Tweets
323+
'statuses/destroy/:id',
324+
'statuses/update',
325+
'statuses/retweet/:id',
326+
'statuses/update_with_media',
327+
328+
// Direct Messages
329+
'direct_messages/destroy',
330+
'direct_messages/new',
331+
332+
// Friends & Followers
333+
'friendships/create',
334+
'friendships/destroy',
335+
'friendships/update',
336+
337+
// Users
338+
'account/settings__post',
339+
'account/update_delivery_device',
340+
'account/update_profile',
341+
'account/update_profile_background_image',
342+
'account/update_profile_colors',
343+
'account/update_profile_image',
344+
'blocks/create',
345+
'blocks/destroy',
346+
'account/update_profile_banner',
347+
'account/remove_profile_banner',
348+
349+
// Favorites
350+
'favorites/destroy',
351+
'favorites/create',
352+
353+
// Lists
354+
'lists/members/destroy',
355+
'lists/subscribers/create',
356+
'lists/subscribers/destroy',
357+
'lists/members/create_all',
358+
'lists/members/create',
359+
'lists/destroy',
360+
'lists/update',
361+
'lists/create',
362+
'lists/members/destroy_all',
363+
364+
// Saved Searches
365+
'saved_searches/create',
366+
'saved_searches/destroy/:id',
367+
368+
// Places & Geo
369+
'geo/place',
370+
371+
// Spam Reporting
372+
'users/report_spam',
373+
374+
// OAuth
375+
'oauth/access_token',
376+
'oauth/request_token',
377+
'oauth2/token',
378+
'oauth2/invalidate_token'
379+
)
380+
);
381+
return $apimethods;
382+
}
383+
224384
/**
225385
* Main API handler working on any requests you issue
226386
*
@@ -589,155 +749,8 @@ protected function _detectMethod($method, $params)
589749
break;
590750
}
591751

592-
$httpmethods = array();
593-
$httpmethods['GET'] = array(
594-
// Timelines
595-
'statuses/mentions_timeline',
596-
'statuses/user_timeline',
597-
'statuses/home_timeline',
598-
'statuses/retweets_of_me',
599-
600-
// Tweets
601-
'statuses/retweets/:id',
602-
'statuses/show/:id',
603-
'statuses/oembed',
604-
605-
// Search
606-
'search/tweets',
607-
608-
// Direct Messages
609-
'direct_messages',
610-
'direct_messages/sent',
611-
'direct_messages/show',
612-
613-
// Friends & Followers
614-
'friendships/no_retweets/ids',
615-
'friends/ids',
616-
'followers/ids',
617-
'friendships/lookup',
618-
'friendships/incoming',
619-
'friendships/outgoing',
620-
'friendships/show',
621-
'friends/list',
622-
'followers/list',
623-
624-
// Users
625-
'account/settings',
626-
'account/verify_credentials',
627-
'blocks/list',
628-
'blocks/ids',
629-
'users/lookup',
630-
'users/show',
631-
'users/search',
632-
'users/contributees',
633-
'users/contributors',
634-
'users/profile_banner',
635-
636-
// Suggested Users
637-
'users/suggestions/:slug',
638-
'users/suggestions',
639-
'users/suggestions/:slug/members',
640-
641-
// Favorites
642-
'favorites/list',
643-
644-
// Lists
645-
'lists/list',
646-
'lists/statuses',
647-
'lists/memberships',
648-
'lists/subscribers',
649-
'lists/subscribers/show',
650-
'lists/members/show',
651-
'lists/members',
652-
'lists/show',
653-
'lists/subscriptions',
654-
655-
// Saved searches
656-
'saved_searches/list',
657-
'saved_searches/show/:id',
658-
659-
// Places & Geo
660-
'geo/id/:place_id',
661-
'geo/reverse_geocode',
662-
'geo/search',
663-
'geo/similar_places',
664-
665-
// Trends
666-
'trends/place',
667-
'trends/available',
668-
'trends/closest',
669-
670-
// OAuth
671-
'oauth/authenticate',
672-
'oauth/authorize',
673-
674-
// Help
675-
'help/configuration',
676-
'help/languages',
677-
'help/privacy',
678-
'help/tos',
679-
'application/rate_limit_status'
680-
);
681-
$httpmethods['POST'] = array(
682-
// Tweets
683-
'statuses/destroy/:id',
684-
'statuses/update',
685-
'statuses/retweet/:id',
686-
'statuses/update_with_media',
687-
688-
// Direct Messages
689-
'direct_messages/destroy',
690-
'direct_messages/new',
691-
692-
// Friends & Followers
693-
'friendships/create',
694-
'friendships/destroy',
695-
'friendships/update',
696-
697-
// Users
698-
'account/settings__post',
699-
'account/update_delivery_device',
700-
'account/update_profile',
701-
'account/update_profile_background_image',
702-
'account/update_profile_colors',
703-
'account/update_profile_image',
704-
'blocks/create',
705-
'blocks/destroy',
706-
'account/update_profile_banner',
707-
'account/remove_profile_banner',
708-
709-
// Favorites
710-
'favorites/destroy',
711-
'favorites/create',
712-
713-
// Lists
714-
'lists/members/destroy',
715-
'lists/subscribers/create',
716-
'lists/subscribers/destroy',
717-
'lists/members/create_all',
718-
'lists/members/create',
719-
'lists/destroy',
720-
'lists/update',
721-
'lists/create',
722-
'lists/members/destroy_all',
723-
724-
// Saved Searches
725-
'saved_searches/create',
726-
'saved_searches/destroy/:id',
727-
728-
// Places & Geo
729-
'geo/place',
730-
731-
// Spam Reporting
732-
'users/report_spam',
733-
734-
// OAuth
735-
'oauth/access_token',
736-
'oauth/request_token',
737-
'oauth2/token',
738-
'oauth2/invalidate_token'
739-
);
740-
foreach ($httpmethods as $httpmethod => $methods) {
752+
$apimethods = $this->getApiMethods();
753+
foreach ($apimethods as $httpmethod => $methods) {
741754
if (in_array($method, $methods)) {
742755
return $httpmethod;
743756
}

0 commit comments

Comments
 (0)
0