我正在为我的网站使用出色的 tmhOAuth php 库。但是,我无法弄清楚如何访问从我的 auth.php 收到的用户令牌/秘密?(比如说,当试图获取当前用户的朋友列表时。)
它在示例中说明:
* 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 示例,但是如何使用我收到的 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);
}