Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP在没有OAuth的情况下获取TwitterAPI JSON文件内容(几乎拥有它)_Php_Json_Api_Twitter_Get - Fatal编程技术网

PHP在没有OAuth的情况下获取TwitterAPI JSON文件内容(几乎拥有它)

PHP在没有OAuth的情况下获取TwitterAPI JSON文件内容(几乎拥有它),php,json,api,twitter,get,Php,Json,Api,Twitter,Get,嘿,伙计们, 我的这个脚本在OAuth上运行得很好,但是我不小心用一个愚蠢的while语句破坏了我350个API的命中率:(我试图在没有OAuth的情况下从Twitter API获取数据,我想不出来(仍然很新),下面是我的 <html> <body> <center> <hr /> <br /> <table border="1"> <tr><td>ScreenName</td><t

嘿,伙计们, 我的这个脚本在OAuth上运行得很好,但是我不小心用一个愚蠢的while语句破坏了我350个API的命中率:(我试图在没有OAuth的情况下从Twitter API获取数据,我想不出来(仍然很新),下面是我的

<html>
<body>
<center>
<hr />
<br />
<table border="1">
<tr><td>ScreenName</td><td>Followed back?</td></tr>
<?php
//twitter oauth deets
$consumerKey    = 'x';
$consumerSecret = 'x';
$oAuthToken     = 'x';
$oAuthSecret    = 'x';
// Create Twitter API objsect 
require_once("twitteroauth.php");
$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
//get home timeline tweets and it is stored as an array
$youfollow = $oauth->get('http://api.twitter.com/1/friends/ids.json?screen_name=lccountdown');
$i = 0;
//start loop to print our results cutely in a table
while ($i <= 20){
$youfollowid = $youfollow[$i];
$resolve = "http://api.twitter.com/1/friendships/exists.json?user_a=".$youfollow[$i]."&user_b=jwhelton";
$followbacktest = $oauth->get($resolve);
//$homedate= $hometimeline[$i]->created_at;
//$homescreenname = $hometimeline[$i]->user->screen_name;
echo "<tr><td>".$youfollowid."</td><td>".$followbacktest."</td></tr>";
$i++;
}
?>
</table>
</center>
</body>
</html>



你回来了吗?
这两个Twitter函数都不需要身份验证,那么如何获得相同的结果呢? 谢谢各位,
Dex

您调用的TwitterOAuth调用不正确。请不要仅使用完整URL作为方法路径,并在哈希数组中传递参数

当foreach也能正常工作时,您可能也不想使用while循环

<?php
//twitter oauth deets
$consumerKey    = 'x';
$consumerSecret = 'x';
$oAuthToken     = 'x';
$oAuthSecret    = 'x';
// Create Twitter API objsect 
require_once("twitteroauth.php");

$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);

//get home timeline tweets and it is stored as an array
$youfollow = $oauth->get('friends/ids', array('screen_name' => 'lccountdown'));
$i = 0;

//start loop to print our results cutely in a table
foreach($youfollow as $id){
  $followbacktest = $oauth->get('friendships/exists', array('user_a' => $id, 'user_b' => 'jwhelton'));
  echo "<tr><td>".$id."</td><td>".$followbacktest."</td></tr>";
}

您正在调用的TwitterOAuth调用不正确。请不要使用完整URL,而只使用散列数组中的方法路径和传递参数

当foreach也能正常工作时,您可能也不想使用while循环

<?php
//twitter oauth deets
$consumerKey    = 'x';
$consumerSecret = 'x';
$oAuthToken     = 'x';
$oAuthSecret    = 'x';
// Create Twitter API objsect 
require_once("twitteroauth.php");

$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);

//get home timeline tweets and it is stored as an array
$youfollow = $oauth->get('friends/ids', array('screen_name' => 'lccountdown'));
$i = 0;

//start loop to print our results cutely in a table
foreach($youfollow as $id){
  $followbacktest = $oauth->get('friendships/exists', array('user_a' => $id, 'user_b' => 'jwhelton'));
  echo "<tr><td>".$id."</td><td>".$followbacktest."</td></tr>";
}