Michelangelo van Dam wrote a neat little article to help with single user Twitter access. What that means is that you can set up a Twitter application and then start tweeting without having to use a username and password. Michelangelo did it in the context of a Zend Framework MVC application and so this blog post is only about doing what he did using the Twitter service as a library instead of the whole kit ‘n kiboodle. Basically, here’s your code.
$config = array(
'username' => 'kpschrade',
'consumerKey' => 'CONSUMER_KEY',
'consumerSecret' => 'CONSUMER_SECRET',
Zend_Oauth_Token_Access::TOKEN_PARAM_KEY => 'TOKEN',
Zend_Oauth_Token_Access::TOKEN_SECRET_PARAM_KEY => 'SECRET'
);
$accessToken = new Zend_Oauth_Token_Access();
$accessToken->setToken($config[Zend_Oauth_Token_Access::TOKEN_PARAM_KEY]);
$accessToken->setTokenSecret($config[Zend_Oauth_Token_Access::TOKEN_SECRET_PARAM_KEY]);
$twitter = new Zend_Service_Twitter();
$twitter->setLocalHttpClient($accessToken->getHttpClient($config));
$result = $twitter->account->verifyCredentials();
if (isset($result->screen_name)) {
echo 'verified';
} else {
echo 'not verified';
}
Van Damn?
@dstockto … did I seriously??? Van Dammit, is what I meant. Will change
Van Damn?