带有标题应用程序/x-www-form-urlencoded 的卷曲发布 [英] curl posting with header application/x-www-form-urlencoded
本文介绍了带有标题应用程序/x-www-form-urlencoded 的卷曲发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$post_data="dispnumber=567567567&extension=6";
$url="http://xxxxxxxx.xxx/xx/xx";
我需要使用带有标题 application/x-www-form-urlencoded
的 cURL php 发布此 $post_data
我是 curl 的新手,任何人都可以帮助解决这个问题.
I need to post this $post_data
using cURL php with header application/x-www-form-urlencoded
i am new for curl any one help this out.
推荐答案
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://xxxxxxxx.xxx/xx/xx");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"dispnumber=567567567&extension=6");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
// further processing ....
if ($server_output == "OK") { ... } else { ... }
?>
这篇关于带有标题应用程序/x-www-form-urlencoded 的卷曲发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文