卷曲与头应用程序/ x-WWW的形式urlen codeD发布 [英] curl posting with header application/x-www-form-urlencoded

查看:251
本文介绍了卷曲与头应用程序/ x-WWW的形式urlen codeD发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ post_data =dispnumber = 567567567&安培;延长= 6;
$ URL =htt​​p://xxxxxxxx.xxx/xx/xx;

我要发布此 $ post_data 使用带有头卷曲的PHP 应用程序/ x-WWW的形式urlen codeD
我是新的卷曲任何一个可以帮助这一点。


解决方案

 < PHP
//
//发送一个HTTP POST到远程站点一个非常简单的PHP示例
//$ CH = curl_init();curl_setopt($ CH,CURLOPT_URLhttp://xxxxxxxx.xxx/xx/xx);
curl_setopt($ CH,CURLOPT_POST,1);
curl_setopt($ CH,CURLOPT_POSTFIELDS,
            dispnumber = 567567567&安培;延长= 6);
curl_setopt($ CH,CURLOPT_HTTPHEADER,阵列('内容类型:应用程序/ x-WWW的形式urlen codeD'));
//接收服务器响应...
curl_setopt($ CH,CURLOPT_RETURNTRANSFER,真正的);$ server_output = curl_exec($ CH);curl_close($ CH);// 进一步处理 ....
如果($ server_output ==确定){...}否则{...}?>

$post_data="dispnumber=567567567&extension=6";
$url="http://xxxxxxxx.xxx/xx/xx";

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的形式urlen codeD发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆