Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
ZendOAuth example for Twitter
include '/path/to/vendor/autoload.php';
use ZendOAuth\Token\Access as AccessToken;
use Zend\Http\Request;
use Zend\Http\Response;
$config = array(
'callbackUrl' => '',
'siteUrl' => '',
'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ',
'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A'
$statusMessage = 'I\'m posting to Twitter using ZendOAuth!';
$token = new AccessToken();
$client = $token->getHttpClient($config);
$client->setParameterPost(array('status' => $statusMessage));
// SSL CA path for HTTPS used by Twitter
$adapter = $client->getAdapter();
'sslcapath' => '/etc/ssl/certs'
$response = $client->send();
echo $response instanceof Response ? 'OK' : 'ERROR';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment