Created
June 19, 2012 18:25
-
-
Save nfx/2955737 to your computer and use it in GitHub Desktop.
Integrate any webservice to PHP project easily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @Service("rest_bindable") | |
*/ | |
class RestBindableConcept { | |
public function getAllUserLists(User $user) { | |
$lists = $this->getListsByName($user->twitterUsername); | |
foreach($lists as $someList) { | |
echo $someList->getNameAndDescription(); | |
} | |
} | |
/** | |
* @param $screen_name | |
* | |
* @see https://dev.twitter.com/docs/api/1/get/lists | |
* @Rest("GET /lists", "twitter", {screen_name=':screen_name'}) | |
* @return TwitterList[] | |
*/ | |
protected function getListsByName($screen_name) {} | |
/** | |
* @param $name | |
* @param $description | |
* @param string $mode | |
* | |
* @see https://dev.twitter.com/docs/api/1/post/lists/create | |
* @Rest("POST /lists/create") | |
* @return TwitterList | |
*/ | |
protected function createNewList($name, $description, $mode = 'public') {} | |
} | |
class TwitterList { | |
public $slug, $name, $uri, $id, $subscriber_count, $full_name, $description; | |
public function getNameAndDescription() | |
{ | |
return $this->name . ': ' . $this->description; | |
} | |
} | |
// .. somewhere in app: | |
public function (\Symfony\Component\DependencyInjection\Container $container) { | |
$binableExample = $container->get('rest_bindable'); | |
$user = $container->get('security.context')->getToken()->getUser(); | |
$binableExample->getAllUserLists($user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hm... as an idea for Guzzle contrib?...