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

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

WBOY
Release: 2016-06-13 12:17:38
Original
850 people have browsed it

关于用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 />
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template