2016-03-29 6 views
1

私はこのライブラリhttps://github.com/J7mbo/twitter-api-phpを使用してTwitter APIを使用しています。POSTメソッドのID intの制限

私は正常に動作GET(showids.php)を使用して、ツイートのIDを渡すために.CSVを使用しています:

<?php 
    require('TwitterAPIExchange.php'); 
    require("auth.php"); 
    $fichero=fopen("tweets.csv","r"); 
    while(!feof($fichero)){ 
     $linea=fgets($fichero); 
     $id=(substr($linea,1,18)); 
     echo ($id."<br />"); 
     $url = "https://api.twitter.com/1.1/statuses/show.json"; 
     $requestMethod = "GET"; 
     $getfield = '?id='.$id; 
     $twitter = new TwitterAPIExchange($settings); 
     $response = $twitter->setGetfield($getfield) 
      ->buildOauth($url, $requestMethod) 
     ->performRequest(); 
    print_r($response); 
    echo("<br />"); 
} 
fclose($fichero); 

を私はPOSTメソッド(delids.php)を使用する場合には、ツイートをカットIDはint limitになります。エラーと

<?php 
require('TwitterAPIExchange.php'); 
require("auth.php"); 
$fichero=fopen("tweets.csv","r"); 
while(!feof($fichero)){ 
    $linea=fgets($fichero); 
     $tid=substr($linea,1,18); 
    echo ($tid."<br />"); 
    $url = sprintf('https://api.twitter.com/1.1/statuses/destroy/%d.json',$tid); 
    echo ($url."<br />"); 
    $method = 'POST'; 
    $params = array(
    'id'=>$tid, 
    ); 
    $twitter = new TwitterAPIExchange($settings); 
    echo $twitter->buildOauth($url,$method) 
     ->setPostfields($params) 
     ->performRequest(); 
    echo("<br />"); 
} 
fclose($fichero); 

IMG:

$url = 'https://api.twitter.com/1.1/statuses/destroy/'.$tid.'.json'); 

私が思うに動作するはずです:int limit

答えて

1

だけではなく、文字列を連結することにより、その間のIDを追加し、sprintfのを使用しないでください。

説明はここにあります: http://php.net/manual/en/function.sprintf.php dは整数を受け入れます。その理由はdが最大整数値で切り捨てられる理由です。

d - the argument is treated as an integer, and presented as a (signed) decimal number.

+0

はい!それでおしまい!ありがとう! :D(私は本当にf **私がそれを見ていない方法を知らない...) –

+0

笑、私たちの最高に起こる^^目の新鮮なペアは時々助けます。私はあなたの状況のやり方で何回も過ごしました:D – Jester