我正在使用class.twitter.php(http://emmense.com/php-twitter/documentation/v11-methods-available/)
我正在使用此代码:
$summize = new summize;
$search = $summize->search('#test');
echo "<pre>";
print_r($search);
echo "</pre>";
输出是:
stdClass Object
(
[results] => Array
(
[0] => stdClass Object
(
[profile_image_url] => http://a1.twimg.com/profile_images/327884498/Tobias_Zielke_ums_logo_normal.jpg
[created_at] => Sun, 03 Jan 2010 10:47:14 +0000
[from_user] => tobiaszielke
[to_user_id] =>
[text] => Ich hoffe unser See ist nicht zugefroren #Trocki #Waterproof #Test
[id] => 7329402210
[from_user_id] => 27862585
[geo] =>
[iso_language_code] => de
[source] => <a href="http://ubertwitter.com" rel="nofollow">UberTwitter</a>
)
....
如何获取[from_user],[text]并将其写入文件?
答案 0 :(得分:1)
使用$search->results[0]->from_user
和$search->results[0]->text
。
要将其写入文件,请查看file_put_contents()。
答案 1 :(得分:1)
$text = $search['results'][0]['from_user'] . ': ' . $search['results'][0]['text'];
file_put_contents('file.txt', $text);