Loop不能用于我的Twitter API

时间:2013-12-25 01:31:03

标签: php twitter

我有一个设置,它收藏和转发特定的推文。出于某种原因,该代码适用于收藏夹,但转推不适用。有谁能看到这个问题?

$method = 'statuses/retweet/'.$url[3];
$amt = "26";
$sub = rand(1,3);
$amt1 = $amt-$sub;

if($_POST['favorite'] == "true" || $_POST['favorite'] == "1"){
 for ($x1=1; $x1<=$amt1; $x1++)
   {
$content = $connection[$x1]->post('favorites/create', array('id' => $url[3]));  
}
}

if($_POST['retweet'] == "true" || $_POST['retweet'] == "1"){
for ($x2=1; $x2<=$amt; $x2++)
   {
$content = twitteroauth_row('statuses/retweet/'.$url[3], $connection[$x2]->post($method), $connection[$x2]->http_code);
}
}

1 个答案:

答案 0 :(得分:1)

你试过声明

吗?
$amt = 26

而不是

$amt="26"

编辑:

for ($x2=1; $x2<=amt; $x2++)
   {
$content = twitteroauth_row('statuses/retweet/'.$url[3], $connection[$x2]->post($method), $connection[$x2]->http_code);
}

您在循环条件

中使用了amt而不是$amt