index.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <script type="text/javascript" src="{{ pathto('_static/prettify.js', 1) }}"></script>
  2. <link rel="stylesheet" type="text/css" href="{{ pathto('_static/prettify.css', 1) }}" />
  3. <link rel="stylesheet" type="text/css" href="{{ pathto('_static/homepage.css', 1) }}" />
  4. <div class="jumbotron masthead">
  5. <div class="container">
  6. <img src="{{ pathto('_static/logo.png', 1) }}" alt="guzzle" width="199" height="260" />
  7. <h1>Guzzle</h1>
  8. <p>Guzzle is a PHP HTTP client<br />&amp; framework for building RESTful web service clients.</p>
  9. <p>
  10. <a class="btn btn-primary btn-lg" href="https://github.com/guzzle/guzzle">View Guzzle on GitHub</a>
  11. <a class="btn btn-default btn-lg" href="{{ pathto('docs') }}">Read the docs</a>
  12. </p>
  13. </div>
  14. </div>
  15. <div class="social">
  16. <ul class="social-buttons">
  17. <li>
  18. <iframe src="http://ghbtns.com/github-btn.html?user=guzzle&repo=guzzle&type=watch&count=true"
  19. allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
  20. </li>
  21. <li>
  22. <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://guzzlephp.org" data-text="Guzzle, PHP HTTP client &amp; framework for building RESTful web service clients" data-via="mtdowling">Tweet</a>
  23. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  24. </li>
  25. <li>
  26. <a href="https://twitter.com/mtdowling" class="twitter-follow-button" data-show-count="false">Follow @mtdowling</a>
  27. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  28. </li>
  29. </ul>
  30. </div>
  31. <div class="container">
  32. <h1>Introducing Guzzle</h1>
  33. <p>Guzzle takes the pain out of sending HTTP requests and the redundancy out of creating web service clients. It's
  34. a framework that includes the tools needed to create a robust web service client, including:
  35. Service descriptions for defining the inputs and outputs of an API, resource iterators for traversing
  36. paginated resources, batching for sending a large number of requests as efficiently as possible.</p>
  37. <ul>
  38. <li>All the power of cURL with a simple interface.</li>
  39. <li>Persistent connections and parallel requests.</li>
  40. <li>Streams request and response bodies</li>
  41. <li><a href="{{ pathto('webservice-client/guzzle-service-descriptions') }}">Service descriptions</a> for quickly building clients.</li>
  42. <li>Powered by the Symfony2 EventDispatcher.</li>
  43. <li>Use all of the code or only <a href="https://packagist.org/packages/guzzle/">specific components</a>.</li>
  44. <li><a href="{{ pathto('plugins/plugins-overview') }}">Plugins</a> for caching, logging, OAuth, mocks, and more</li>
  45. <li>Includes a custom node.js webserver to <a href="{{ pathto('testing/unit-testing') }}">test your clients</a>.</li>
  46. </ul>
  47. <div class="center-announcement">
  48. Guzzle is now part of Drupal 8 core and powers the official <a href="https://github.com/aws/aws-sdk-php">AWS SDK for PHP</a>
  49. </div>
  50. <h2>GitHub Example</h2>
  51. <pre class="prettyprint">&lt;?php
  52. require_once 'vendor/autoload.php';
  53. use Guzzle\Http\Client;
  54. // Create a client and provide a base URL
  55. $client = new Client('https://api.github.com');
  56. // Create a request with basic Auth
  57. $request = $client->get('/user')->setAuth('user', 'pass');
  58. // Send the request and get the response
  59. $response = $request->send();
  60. echo $response->getBody();
  61. // >>> {"type":"User", ...
  62. echo $response->getHeader('Content-Length');
  63. // >>> 792
  64. </pre>
  65. <h2>Twitter Example</h2>
  66. <pre class="prettyprint">&lt;?php
  67. // Create a client to work with the Twitter API
  68. $client = new Client('https://api.twitter.com/{version}', array(
  69. 'version' => '1.1'
  70. ));
  71. // Sign all requests with the OauthPlugin
  72. $client->addSubscriber(new Guzzle\Plugin\Oauth\OauthPlugin(array(
  73. 'consumer_key' => '***',
  74. 'consumer_secret' => '***',
  75. 'token' => '***',
  76. 'token_secret' => '***'
  77. )));
  78. echo $client->get('statuses/user_timeline.json')->send()->getBody();
  79. // >>> {"public_gists":6,"type":"User" ...
  80. // Create a tweet using POST
  81. $request = $client->post('statuses/update.json', null, array(
  82. 'status' => 'Tweeted with Guzzle, http://guzzlephp.org'
  83. ));
  84. // Send the request and parse the JSON response into an array
  85. $data = $request->send()->json();
  86. echo $data['text'];
  87. // >>> Tweeted with Guzzle, http://t.co/kngJMfRk
  88. </pre>
  89. </div>
  90. <script type="text/javascript">prettyPrint();</script>