Skip to content

Instantly share code, notes, and snippets.

@nfx
Created June 19, 2012 18:25
Show Gist options
  • Save nfx/2955737 to your computer and use it in GitHub Desktop.
Save nfx/2955737 to your computer and use it in GitHub Desktop.
Integrate any webservice to PHP project easily
<?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);
}
@nfx
Copy link
Author

nfx commented Oct 13, 2013

hm... as an idea for Guzzle contrib?...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment