Created
May 27, 2012 01:36
-
-
Save alganet/2795839 to your computer and use it in GitHub Desktop.
A HATEOAS, RESTful HTTP client for PHP.
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 | |
use Respect\Http\Hypermedia as hy; | |
//All synopses from movies featuring Will Smith as an actor. | |
hy::with("netflix", "http://api.netflix.com/") | |
->with("schema", "http://schemas.netflix.com/") | |
->get("netflix/catalog/people", array('term' => 'Will Smith')) | |
->rel("schema/catalog/person/filmography") | |
->rel("schema/catalog/titles/synopsis")->send(); | |
/* | |
Sample above line by line: | |
1 - Registers a netflix namespace to shorten further method calls | |
2 - Register a schema namespace | |
3 - GETs a page from the Netflix API | |
4 - Searches links related as filmographies. | |
5 - On links related, searches for synopses. | |
See the Netflix API Reference for more information on REST and Hypermedia relations. | |
Several requests on each Netflix APIs are done. Caching can help heavy clients if necessary, constant open sockets could also help using stream_select(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alexandre, is the Respect\Http\Hypermedia implementation available somewhere? It looks very interesting!