2012-01-04 10 views
0

私はPHPからStreaming APIを使用しようとしていますが、Matt HarrisのコードStreaming codeを使用しますが、exec関数neversでコードを実行すると、エラーもなくエラーも表示されます。私は何を間違えているのですか?なぜ私のストリーミングAPIコードはPHPで何もエコーしない(Twitterアプリ)?

これは私のコードです:

<?php 

/** 
* Very basic streaming API example. In production you would store the 
* received tweets in a queue or database for later processing. 
* 
* Instructions: 
* 1) If you don't have one already, create a Twitter application on 
*  https://dev.twitter.com/apps 
* 2) From the application details page copy the consumer key and consumer 
*  secret into the place in this code marked with (YOUR_CONSUMER_KEY 
*  and YOUR_CONSUMER_SECRET) 
* 3) From the application details page copy the access token and access token 
*  secret into the place in this code marked with (A_USER_TOKEN 
*  and A_USER_SECRET) 
* 4) In a terminal or server type: 
*  php /path/to/here/streaming.php 
* 5) To stop the Streaming API either press CTRL-C or, in the folder the 
*  script is running from type: 
*  touch STOP 
* 
* @author themattharris 
*/ 

function my_streaming_callback($data, $length, $metrics) { 
    echo $data .PHP_EOL; 
    return file_exists(dirname(__FILE__) . '/STOP'); 
} 

require 'tmhOAuth.php'; 
require 'tmhUtilities.php'; 
$tmhOAuth = new tmhOAuth(array(
    'consumer_key' => 'Y1qoRrUSevAnfpzPJiVpQ', 
    'consumer_secret' => 'usZvJYGl1y5IRmImyNSVRGyOajMzsBMubzZND7Uh4', 
    'user_token'  => '435894914-UHEEk87wPsiYI4tjSOxYiVvcKZdYon5qSxI376nN', 
    'user_secret'  => '1MDdrNBaMZLStfHmngmEjaW6Lkfy5cNR9ySXiqaGw', 
)); 

$method = 'https://stream.twitter.com/1/statuses/filter.json'; 

// show Tweets which contan the word twitter OR have been geo-tagged within 
// the bounding box -122.41,37.77,-122.40,37.78 OR are by themattharris 

$params = array(
    'track'  => 'soyprole', 
    // Around Twitter HQ. First param is the SW corner of the bounding box 
    'locations' => '-122.41,37.77,-122.40,37.78', 
    'follow' => '777925' // themattharris 
    ); 

$tmhOAuth->streaming_request('POST', $method, $params, 'my_streaming_callback'); 



// output any response we get back AFTER the Stream has stopped -- or it errors 
tmhUtilities::pr($tmhOAuth); 

、スクリプト実行されるコード:

<?php 


exec("C:\wamp\www\appTwitterNuevo3\script.php"); 

?> 
+0

を、あなたはdisable_functions = execのようなものがありますか...? –

+0

@cillosisいいえ私はそれを持っていません – bentham

答えて

1
exec("C:\wamp\www\appTwitterNuevo3\script.php"); 

あなたはPHPファイルを実行する方法はありません。また無効な\(バックスラッシュ)があります。

あなたはこれらのいずれかを試してみたいことがあります:あなたのphp.inファイルで

include("C:\\wamp\\www\\appTwitterNuevo3\\script.php"); 

または

system("C:\\wamp\\php\\php.exe C:\\wamp\\www\\appTwitterNuevo3\\script.php"); 
+0

回答ありがとう、私はそれらと一緒に試みますが、それは私が思っているのと同じ結果ですそれはストリーミングコードである – bentham

+0

ストリーミングコードは問題ありません。 –

+0

もう誰かを助ける? – bentham

関連する問題