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.
没有评论:
发表评论