Home >Backend Development >PHP Tutorial >关于用POST方法发送JSON数据的有关问题

关于用POST方法发送JSON数据的有关问题

WBOY
WBOYOriginal
2016-06-13 12:17:38840browse

关于用POST方法发送JSON数据的问题。

本帖最后由 jxflll 于 2015-04-07 16:36:47 编辑 stream_context_create用这个函数POST方法发送json对象的例子。有的麻烦发段代码上来。谢谢了。不要用curl
------解决思路----------------------
不知道你具体的需求,给个代码片段
$opts = array(<br />    'http' => array(<br />        'method' => 'POST',<br />        'header' => 'content-type:application/x-www-form-urlencoded',<br />        'user_agent' => $_SERVER['HTTP_USER_AGENT'],<br />        'content' => http_build_query($data)<br />    )    <br />);<br /> <br />$context = stream_context_create($opts);<br />$result = file_get_contents($url, false, $context);<br />
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn