Zend公司的OAuth与Twitter单一访问令牌 [英] Zend OAuth with twitter single access tokens
问题描述
我正在开发它要求用户在使用Twitter和OAuth签名的应用程序。一切工作就好了感谢Zend_OAuth。问题是,Web应用程序也会打几个电话到Twitter API但这些将在内部,无需认证的处理。 Twitter的开发提供了一个'ACCESS_TOKEN'和'access_token_secret键用于此目的(这里所说的 HTTP://dev.twitter .COM /页/ oauth_single_token )
I'm developing an application where it requires users to sign in using twitter and OAuth. Everything works just fine thanks to Zend_OAuth. The problem is that the web app will also make some calls to the twitter API but these will be handled internally without the need of authenticating. Twitter Dev provides an 'access_token' and 'access_token_secret' keys for this purpose (Mentioned here http://dev.twitter.com/pages/oauth_single_token )
问题是,我不能让Zend_OAuth发挥好与现有的访问令牌。是否有任何人谁可以用code几行我怎样才能使我现有的密钥的API调用,而不被重定向到Twitter的授权页面帮助吗?我知道这是可以做到。
The problem is that I can't get Zend_OAuth to play nice with existing access tokens. Is there anyone who can help with a few lines of code how can I make an API call with my existing keys without being redirected to Twitter's Authorize page ? I know it can be done.
PS。如果可能的话,我不想使用外部库就像dev.twitter.com提到的那些 - 正是Zend框架将提供
PS. If possible, I don't want to use external libraries like the ones mentioned in dev.twitter.com - just what Zend Framework is offering
谢谢!
推荐答案
通过张贴在Twitter需要ZF版本1.10.8最小code是:
With ZF version 1.10.8 minimal code required to post on Twitter is:
$token = new Zend_Oauth_Token_Access;
$token->setParams(array(
'oauth_token' => 'REPLACE_WITH_TOKEN',
'oauth_token_secret' => 'REPLACE_WITH_TOKEN_SECRET'
));
$twitter = new Zend_Service_Twitter(array(
'consumerKey' => 'REPLACE_WITH_CONSUMER_KEY',
'consumerSecret' => 'REPLACE_WITH_CONSUMER_SECRET',
'accessToken' => $token
));
$response = $twitter->status->update('REPLACE WITH MESSAGE');
所有令牌和秘密可以在 http://dev.twitter.com
这篇关于Zend公司的OAuth与Twitter单一访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!