jquery - How to receive and print out json data using php?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-14 10:49:41
0
3
761

Suppose another domain provides me with a json
How do I get it and print it out using php? ? !

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(3)
为情所困
file_get_contents('php://input');
$_REQUEST
给我你的怀抱
// 初始化cURL
$ch = curl_init();

// 设置选项
curl_setopt($ch, CURLOPT_URL, '你的网址');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);

// 执行并获取文档内容
$contents = curl_exec($ch);

// 释放 curl
curl_close($ch);

// 打印获得的数据
print_r( json_decode($contents) );
世界只因有你

The two people above said the same thing, so I won’t say more. The question is, is your json a standard json? If so, I just assume that you collect it from JD.com (not counting JD.com providing it to you) ), the json obtained is used by javascript, which is not standard for php. You must complete the quotation marks before it can be used by php

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template