我请求Facebook Users tagged_places和FB API V-4。
一旦我有了我正在做的数据
<?php echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>'; ?>当数据打印在屏幕上时,它看起来就像thic。
[data] => Array
(
[0] => stdClass Object
(
[id] => 111111111111111
[created_time] => 1905-01-01T08:00:00+0000
[place] => stdClass Object
(
[id] => 1111111111111
[location] => stdClass Object
(
[latitude] => 36.1313
[longitude] => -95.9373
)
[name] => Tulsa, Oklahoma
)
)
[1] => stdClass Object
(
[id] => 11111111111
[created_time] => 2014-05-30T21:41:11+0000
[place] => stdClass Object
(
[id] => 111111111111111
[location] => stdClass Object
(
[city] => Okmulgee
[country] => United States
[latitude] => 35.623012460758
[longitude] => -95.972782756346
[state] => OK
[street] => 104 S Morton Ave
[zip] => 74447-5022
)
[name] => Ike's Downtown Pub & Eatery
)
)如何将这些信息保存到数据库中?
发布于 2014-06-16 20:15:07
这是如何检索tagged_places中的每个值的方法
$graphObject['tagged_places']->data->id
$graphObject['tagged_places']->data->created_time
$graphObject['tagged_places']->data->place->id
$graphObject['tagged_places']->data->place->location->latitude
$graphObject['tagged_places']->data->place->location->longitude
$graphObject['tagged_places']->data->place->location->state
$graphObject['tagged_places']->data->place->location->street
$graphObject['tagged_places']->data->place->location->zip
$graphObject['tagged_places']->data->place->name这就是如何将它们插入到MySQL数据库中,
$stmt = $con->prepare('
INSERT INTO this_should_be_your_table_name
(id, created_time, place_id, latitude, longitude, state, street, zip, name)
VALUES
(?, ?, ?, ?, ?, ?)
');
foreach($graphObject['tagged_places']->data as $data) {
$stmt->execute(array(
$data->id,
$data->created_time,
$data->place->id,
$data->place->location->latitude,
$data->place->location->longitude,
$data->place->location->state,
$data->place->location->street,
$data->place->location->zip,
$data->place->name
));
}https://stackoverflow.com/questions/24128278
复制相似问题