从其他站点检索json值到当前站点

时间:2014-11-06 10:55:27

标签: php json codeigniter

如何从url

获取json值

URL:

admin-ajax.php?action=cfdb-login&cfdb-action=cfdb-export&form=contact%20form%20mail&enc=JSON&user_login=admin&user_password=admin

内容:

values
[
{"Submitted":"2014-11-06 10:44:29 +00:00","your-name":"ayyan","your-email":"test@mail.com","your-subject":"demo testing","your-message":"ayyantesting","Submitted Login":"admin","Submitted From":"127.0.0.1"},
{"Submitted":"2014-11-06 08:31:32 +00:00","your-name":"demo","your-email":"demo@mail.com","your-subject":"demo testing","your-message":"test the demo details","Submitted Login":"admin","Submitted From":"127.0.0.1"},
{"Submitted":"2014-11-06 08:18:26 +00:00","your-name":"ayyan","your-email":"test@mail.com","your-subject":"downloading hotel website","your-message":"test","Submitted Login":"admin","Submitted From":"127.0.0.1"}
]

我需要将此数据用于我当前的网站。

1 个答案:

答案 0 :(得分:1)

$url = "htp://www.example.com". /* Don't forget the http www part! */
    "admin-ajax.php?action=cfdb-login&cfdb-action=cfdb-export&form=contact%20form%20mail&enc=JSON&user_login=admin&user_password=admin";
$variable = json_decode(file_get_contents( $url ));
print_r($variable);