News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Michael Dowling:
Guzzle-Ring and Future Responses
September 30, 2014 @ 09:36:32

Michael Dowling has a new post to his site today talking about the work that's being done on the upcoming release of the Guzzle HTTP client. In the post he talks about a major change in how it allows for asynchronous requests and the work on Guzzle-Ring to make it happen.

Guzzle 4 has been out for a little over six months. It has proven to be leaps and bounds better than Guzzle 3, and I've been very happy with the design so far. However, after the release of Guzzle 4, I've received feedback from numerous members of the PHP community that can be boiled down to "Guzzle needs async support." While Guzzle has always had the ability to send requests concurrently using a pool of requests, there was not a way to send asynchronous requests.

After a couple months of work and borrowing concepts from Clojure, I've created Guzzle-Ring, an extremely simple adapter and middleware library for PHP (not just Guzzle) that can power both clients and servers for both synchronous and asynchronous requests.

The Guzzle-Ring reduces the need for the previous complexity of creating multiple adapters, which ended up with the adapters knowing too much about the request itself. He introduces the Guzzle-Ring system that will be included in Guzzle v5, heavily influenced by Clojure. The adapter makes the request as simple as passing in an array and makes use of "futures" to handle the request/response cycle. He also talks some about creating middleware piece that helps integrate it into your application, wrapping functionality inside of another method. He illustrates all of this with code examples and includes others such as fetching of future responses, sending requests concurrently and the Guzzle-Ring server adapters.

0 comments voice your opinion now!
guzzle guzzlering http client asynchronous request futures guzzle5 clojure

Link: http://mtdowling.com/blog/2014/09/28/guzzle-ring/

SitePoint PHP Blog:
Diffbot Crawling with Visual Machine Learning
August 01, 2014 @ 11:37:12

On the SitePoint PHP blog Bruno Skvorc has posted a tutorial showing you how to use the Diffbot service to extract data from any page. He introduces both the service itself and walks you through a simple request via Guzzle.

Have you ever wondered how social networks do URL previews so well when you share links? How do they know which images to grab, whom to cite as an author, or which tags to attach to the preview? Is it all crawling with complex regexes over source code? Actually, more often than not, it isn't. [...] If you want to build a URL preview snippet or a news aggregator, there are many automatic crawlers available online, both proprietary and open source, but you seldom find something as niche as visual machine learning. This is exactly what Diffbot is - a "visual learning robot" which renders a URL you request in full and then visually extracts data, helping itself with some metadata from the page source as needed.

He uses a combination of a Laravel installation (via a Homestead instance) and a Guzzle request using a fetched token. The service offers a 10k call limit on a 7 day free trial, so you can sign up and grab your token there. He includes code for an example request fetching a SitePoint page and parsing out the tags. He also briefly looks at the custom handling diffbot allows based on CSS-type rules.

0 comments voice your opinion now!
diffbot parse data service api guzzle homestead tutorial introduction

Link: http://www.sitepoint.com/diffbot-crawling-visual-machine-learning/

SitePoint PHP Blog:
Using Guzzle with Twitter via Oauth
July 31, 2014 @ 10:54:01

Continuing on with his series about using the Guzzle PHP HTTP library, Miguel Ibarra Romero is back with this new post showing how to connect your PHP application, via Guzzle, to the Twitter OAuth protected service.

In a previous article, we found out about Guzzle and how it can aid us in the task of establishing communication with third party APIs over HTTP. We used it to get the output of a random number generator and for basic interaction with Github's API. [...] While interacting with Github's API we discovered that it supports basic authentication (sending plain username/password). But what if the API we want to use just offers OAUTH authentication?

He shows how to use Guzzle's own OAuth subscriber to make a basic connection to the API. He walks you through the installation of the subscriber (via Composer) and an example of its use. He explains each part of the code, giving a little background on where it fits into the OAuth request and where to put your API secret and key to make the connection work. Finally, he includes the code to handle the callback once the OAuth request is successful, grabbing the token data and adding it to the user session.

0 comments voice your opinion now!
oauth twitter guzzle http library tutorial

Link: http://www.sitepoint.com/using-guzzle-twitter-via-oauth/

CodeSamplez.com:
PHP HTTP Request With Guzzle
June 12, 2014 @ 11:55:07

If you're making HTTP requests in your applications and you haven't looked into using Guzzle, you're missing out on one of the most powerful, flexible HTTP tools out there. In this new post to the CodeSamplez.com site they introduce you to the tool and show you how to make a few sample requests.

If you are consuming some kind of API with complex PHP HTTP requests which doesn't provide a clean wrapper library, I can feel the nightmare you might be having. Same could be happen if you are yourself writing such kind of API wrapper as well. Here, I will try to introduce you with guzzle library and getting a quick start. This article is targeted for complete beginners, so if you are already somewhat experienced, you either might skip this or review it and help me improve it to fit as a robust getting started tutorial.

He covers some of the things that can be done with Guzzle (including connecting to APIs and scraping site data) and briefly mentions some alternatives to the tool. Code is included to make a first request: a simple call to the GitHub API that fetches URL information for other resources. He also includes an example of making a POST request and using the OAuth module that comes with Guzzle, making those requests easier.

0 comments voice your opinion now!
http request guzzle introduction tutorial

Link: http://codesamplez.com/programming/php-http-request-guzzle

Michael Dowling:
Guzzle 4.0
March 31, 2014 @ 13:57:08

Michael Dowling has announced the release of Guzzle 4.0.0 on his site today. Guzzle is one of the most widely used, popular HTTP clients in the PHP community today. Its used in both corporate and open source projects as a primary means for making HTTP requests and RESTful web service clients.

Guzzle 4.0 has arrived! The new version of Guzzle is now simpler, faster, more flexible, and more powerful than ever. [...] Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes the pain out of consuming web services.

He includes a quick example of it in use making a request to the GitHub API to fetch user information. He lists out some of the changes made in this release but points to this other post for the full list. He's also tagged other related projects to match this 4.0.0 release including Guzzle Streams and the Log Subscriber.

0 comments voice your opinion now!
guzzle http client restful release v4

Link: http://mtdowling.com/blog/2014/03/29/guzzle4/

Lorna Mitchell:
Using Composer in an Existing Project
August 20, 2013 @ 10:18:38

Lorna Mitchell has a recent post to her site showing you how to use Composer within an existing project that might not have the same Composer-expected structure. Composer is a package and dependency manager for PHP.

I've got an application (okay, scratty PHP script) which glues together some API things and shows them onto a dashboard for me. Recently, I updated it to use Guzzle as the consuming client, since twitter now needs me to authenticate (I wrote about that if you're interested), and I used Composer to bring the new library in. It was very simple so I thought I'd share it as it's quite minimal example, and those are my favourite kind.

She includes a brief "getting started" for those not already familiar with Composer and shows a sample composer.json file that pulls in the Guzzle HTTP library. Then calling the "install" with Composer pulls in the files in the right place and all you have to do is add the needed require_once include to your autoloading process. Composer handles the rest.

0 comments voice your opinion now!
composer existing project guzzle install introduction requireonce

Link: http://www.lornajane.net/posts/2013/using-composer-in-an-existing-project

VG Tech:
PHP Perform Requests in Parallel
July 23, 2013 @ 10:58:11

On the VG Tech blog today Espen Hovlandsdal has a quick tutorial showing you how to run cURL requests in parallel using the curl_multi_* functions included in PHP.

Ever had to request multiple HTTP-resources in your web application? Often, you need data from one request to be able to request the second - in this case there is little you can do but wait for the first to return. However, if the requests are not dependent on each other, you can use a pretty cool trick: curl_multi_*.

He first gives a single-threat example, showing how you might loop through a set of URLs to make the request and get the response. As an alternative, he shows the "multi" version right after. It sets up a "queue" of handles to different requests and executes them until they stop returning data. He also includes an example using the Guzzle HTTP client that makes it look cleaner and wraps some additional functionality around the requests.

0 comments voice your opinion now!
request parallel curl multiple tutorial guzzle

Link: http://tech.vg.no/2013/07/23/php-perform-requests-in-parallel

Lorna Mitchell:
Twitter Search API Using PHP and Guzzle
July 11, 2013 @ 12:49:45

Lorna Mitchell has a new post to her site today showing how she connected to Twitter with Guzzle, the popular PHP-based HTTP client (also used in the Amazon Web Services PHP client).

In case you missed it, Twitter updated their APIs recently, so that you have to authenticate to use even their search APIs to return publicly-available results. This is an increasing trend for API providers, to provide either very limited or nonexistent access for unauthenticated users, I think so they can rate limit consumers that swamp them. To cut a long story short, that meant I needed to update my dashboards that keep an eye on twitter searches to do more than just call file_get_contents in the general direction of the right URL.

She walks you through the creation of the client complete with the OAuth plugin (included with Guzzle) to make an OAuth request to api.twitter.com. With the client created, she shows a simple search call to the "tweets" endpoint.

0 comments voice your opinion now!
twitter search guzzle tutorial http client oauth api

Link: http://www.lornajane.net/posts/2013/twitter-search-api-using-php-and-guzzle

Gonzalo Ayuso:
How to configure Symfony's Service Container to use Twitter API
February 05, 2013 @ 10:53:19

In this recent post to his site Gonzalo Ayuso shows how to use the Symfony2 service container to interact directly with the Twitter API via an OAuth plugin.

If we are working within a Symfony2 application or a PHP application that uses the Symfony's Dependency injection container component you can easily integrate this simple script in the service container. I will show you the way that I use to do it.

His sample code uses the Guzzle HTTP library and some configuration options from a YAML file to create a new service hooked into the Twitter API with his credentials. He then imports it via his services configuration and shows an example of it in action - getting the latest contents of his timeline.

0 comments voice your opinion now!
symfony2 service container guzzle twitter api


Amazon Web Services Blog:
Version 2 of the AWS SDK for PHP (now with Guzzle)
November 15, 2012 @ 14:57:49

The Amazon Web Services group has recently released an updated version of their SDK for PHP and at it's heart is the open source project Guzzle (a HTTP client framework).

The new SDK is built on top of the Guzzle HTTP client framework, which provides increased performance and enables event-driven customization. Each AWS service client extends the Guzzle client and describes operations on the service using a service description file. The SDK now manages persistent connections for both serial and parallel requests. It detects transient network failures, with automatic retries using truncated exponential backoff. Support for event hooks (via the Symfony2 EventDispatcher) allows you to implement custom, event-driven behavior.

In the AWS post about the update, they give you a few code snippets showing this updated version in use. This completely reworked version of the SDK is not compatible with the previous version, so you'll need to consult their migration guide to bring things up to date.

0 comments voice your opinion now!
aws amazon webservices guzzle opensource http client version release sdk



Community Events





Don't see your event here?
Let us know!


opinion interview list zendserver symfony language update series introduction install framework release tips community laravel deployment library package api podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework