我尝试解析来自twitter api的响应,以便为GeoJSon创建输出。
但我无法检索值以创建我的$ features变量
$original_data = json_decode($response, true);
$features = array();
foreach($original_data as $tweet)
{
$features[] = array(
'type' => 'Feature',
'properties' => array(
'NAME' => $tweet->text
),
'geometry' => array(
"type"=> "Point",
"coordinates"=> array(
"todo",
"todo"
)
)
);
}
$new_data = array(
'type' => 'FeatureCollection',
'features' => $features
);
$ original_data输出:
array(2) {
["statuses"]=>
array(15) {
[0]=>
array(25) {
["created_at"]=>
string(30) "Mon Jul 25 09:59:38 +0000 2016"
["id"]=>
int(757515646938804225)
["id_str"]=>
string(18) "757515646938804225"
["text"]=>
string(117) "#wp_Dev #ajax #stackoverflow How to handle big integer numbers in JSON response in Javascript"
["truncated"]=>
bool(false)
["entities"]=>
array(4) {
["hashtags"]=>
我的输出必须是这样的:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"NAME": "name"
},
"geometry": {
"type": "Point",
"coordinates": [
"todo",
"todo"
]
}
},