我使用以下教程编写了一个 twitter api 应用程序:
http://www.youtube.com/watch?v=GQaPt-gQVRI
如何修改脚本以生成特定于用户的时间线流,以便应用程序在运行时显示用户的时间线流而不是我的(因为我编写了应用程序,因此它具有我的 Twitter 凭据)
谢谢
php 应用程序使用以下方法验证我的 twitter 凭据:
<?php
require 'tmhOAuth.php'; // Get it from: https://github.com/themattharris/tmhOAuth
// Use the data from http://dev.twitter.com/apps to fill out this info
// notice the slight name difference in the last two items)
$connection = new tmhOAuth(array(
'consumer_key' => 'my key',
'consumer_secret' => 'my secret',
'user_token' => 'my token', //access token
'user_secret' => 'my user secret' //access token secret
));
// set up parameters to pass
$parameters = array();
if ($_GET['count']) {
$parameters['count'] = strip_tags($_GET['count']);
}
if ($_GET['screen_name']) {
$parameters['screen_name'] = strip_tags($_GET['screen_name']);
}
if ($_GET['twitter_path']) { $twitter_path = $_GET['twitter_path']; } else {
$twitter_path = '1.1/statuses/user_timeline.json';
}
$http_code = $connection->request('GET', $connection->url($twitter_path), $parameters );
if ($http_code === 200) { // if everything's good
$response = strip_tags($connection->response['response']);
if ($_GET['callback']) { // if we ask for a jsonp callback function
echo $_GET['callback'],'(', $response,');';
} else {
echo $response;
}
} else {
echo "Error ID: ",$http_code, "<br>\n";
echo "Error: ",$connection->response['error'], "<br>\n";
因此,无需在 api 调用中传递新的用户名,我如何添加一个片段来要求用户登录?如果我添加该片段供用户登录,api会自动用用户的身份验证字符串填充吗?