【发布时间】:2012-06-08 21:29:46
【问题描述】:
我正在为我的网站使用出色的 tmhOAuth php 库。但是,我无法弄清楚如何访问从我的 auth.php 收到的用户令牌/秘密? (比如说,当试图获取朋友的当前用户列表时。)
在the example中说明:
* Although this example uses your user token/secret, you can use
* the user token/secret of any user who has authorised your application.
我已成功使用auth.php example,但如何使用我收到的 USER 令牌/密码?就像在示例中一样,它只是这样陈述:
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'YOUR_CONSUMER_KEY',
'consumer_secret' => 'YOUR_CONSUMER_SECRET',
'user_token' => 'A_USER_TOKEN',
'user_secret' => 'A_USER_SECRET',
));
显然,硬编码对我不起作用,所以,简单来说,我想知道当前登录用户的令牌/秘密在哪里?
这是一个存储凭证的示例,我想:
// already got some credentials stored?
} elseif ( isset($_SESSION['access_token']) ) {
$tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
if ($code == 200) {
$resp = json_decode($tmhOAuth->response['response']);
echo $resp->screen_name;
} else {
outputError($tmhOAuth);
}
【问题讨论】: