WARNING:
Please note that this article was published a long time ago. The information contained might be outdated. For a new project I needed to publish messages on Twitter via Twitter REST API. Since I'm a Zend Framework fan, I choose to give I started by running The library got downloaded and I was able to test my PHP script doing some "copy & paste" from the documentation: But as result I got a fatal error: To make a long story short I found out that the After running This post should make you interested in trying Zend Service Twitter.ZendServiceTwitter
client a try.php composer.phar install
using a simple composer.json
file:{
"require": {
"zendframework/zendservice-twitter": "2.1.0"
}
}
<?php
include "vendor/autoload.php";
$config = array(
'access_token' => array(
'token' => 'TOKEN',
'secret' => 'SECRET',
),
'oauth_options' => array(
'consumerKey' => 'CONSUMER_KEY',
'consumerSecret' => 'CONSUMER_SECRET',
),
'http_client_options' => array(
'adapter' => 'ZendHttpClientAdapterCurl',
'curloptions' => array(
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
),
),
);
$twitter = new ZendServiceTwitterTwitter($config);
$response = $twitter->search->tweets('#zf2');
$tweets = $response->statuses;
var_dump($tweets);
PHP Fatal error: Call to a member function connect() on a non-object
in /Users/me/Development/zf2-twitter-test/vendor/zendframework/zend-http/Zend/Http/Client.php on line 1359
ZendOAuthClient::getAdapter()
method wasn't confirm to the parent class. So I forked <https://github.com/zendframework/ZendOAuth>
, changed the code to what I think it's a solution to the problem, committed and finally synced to my dev-master
branch. At this point I modified my local composer.json
adding my git repository and specifying the dev-master
branch for zendframework/zendoauth
:{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/lorenzoferrarajr/ZendOAuth.git"
}
],
"require": {
"zendframework/zendoauth": "dev-master",
"zendframework/zendservice-twitter": "2.1.0"
}
}
php composer.phar update
all started working great.