我想从示例 Twitter 数据中提取推文,例如http://pastebin.com/AvHnxKpz
我尝试使用 PHP 函数 json_decode 然后循环输出“文本”字段但没有任何乐趣,特别是当输入是多个对象时,因为它在示例数据中。
我可以使用$json = json_decode($input, true);
然后$json['text']
从单个条目中提取推文,例如
{"created_at":"Sun Apr 28 17:31:15 +0000 2013","id":328562066359205888,"id_str":"328562066359205888","text":"RT @NameIsLauraa: I think it's cute when guys are ticklish \u263a"}
但是,当输入包含大量条目时,例如
{"created_at":"Sun Apr 28 17:31:15 +0000 2013","id":328562066359205888,"id_str":"328562066359205888","text":"RT @NameIsLauraa: I think it's cute when guys are ticklish \u263a"}
{"created_at":"Sun Apr 28 17:31:15 +0000 2013","id":328562066329837568,"id_str":"328562066329837568","text":"RT @R_Piz23: Lupa lak nak post caramel pudding yg sedap aku buat dulu tu @Ainie_Kim ..terliur la kau kan.. nasib la badan..homemade aiskrim\u2026"}
代码不起作用。