Recently I got task to implement Twitter feed into application built on Zend Framework 2. I found that Zend Framework 2 is having ZendService\Twitter\Twitter library which provides a client for the Twitter API so I wanted to give it advantage over other libraries available on Packagist. Using this service it’s possible to get and update your status, reply to friends, direct message friends, block and ublock users, follow/unfollow people, mark tweets as favorites, and much more. I thought It would be easy and it actually was except one tiny quirk in official documentation of package.
First of all we have to add dependency into composer.json file
and update only this package
php composer.phar update zendframework/zendservice-twitter
Our application can now use this package to use Twitter API. You have to get four keys from twitter to use it’s API :
- Access token – (array key value – ‘twitter-access-token-here’)
- Access token secret – (array key value – ‘twitter-access-secret-here’)
- API key – (array key value – ‘twitter-consumer-key-here’)
- API secret – (array key value – ‘twitter-consumer-secret-here’)
You will get this key after creating new app on this link. When you finish with this you can use this API in you Zend 2 application.