发送POST请求在request中有以次data内容

WBOY
Release: 2016-06-13 11:57:22
Original
1035 people have browsed it

发送POST请求在request中有以下data内容
接口实例:
http://199.199.99.199:8080/cloudTVPlatform/external/api?act=notifyNewDeveloper&PID=CloudTVDN&pversion=1.0&format=JSON
请求方式:POST
请求URL参数说明: 
act:操作类型,notifyNewDeveloper,必须
pversion:协议版本,默认为1.0 
PID:合作伙伴代码PID,填写CloudTVDN,必须
format:返回的数据格式,支持XML和JSON,默认为JSON
通知数据(POST DATA)实例
POST请求在request中获取参数data内容如下
{
    " developerCount ": 2,
    "data": [
        {
            "originalID": "123",
            "developerName": "liux",
            "developerType": "个人",
            "trueName": "刘",
            "eMail": "[email protected]",
            "phone": "86-10-62565615-208",
            "mobile": "86-13900000000",
            "fax": "86-10-62565615-208",
            "ECURL": "http://DNS/123.JPG",
            "CRURL": "",
            "CTURL": "",
            "registerTime": "2014-04-02 14:14:19"
        },
        {
            "originalID": "124",
            "developerName": "liux1",
            "developerType": "公司",
            "trueName": "百度",
            "eMail": "[email protected]",
            "phone": "86-10-62565615-208",
            "mobile": "86-13900000000",
            "fax": "86-10-62565615-208",
            "ECURL": "http://DNS/124.JPG",
            "CRURL": " http://DNS/125.JPG ",
            "CTURL": " http://DNS/126.JPG ",
            "registerTime ": "2014-04-02 14:14:19"
        }
    ]
}

返回数据:
返回数据格式:JSON
返回实例:
{
    "resultCode": "Success",
    "resultMessage": "成功处理"
}
那是客户端提供的接口,而我在服务器端我调用这接口,然后用POST传给他data内容,这应该怎么做啊?我是新手~~~
------解决方案--------------------

引用:
Quote: 引用:

php使用curl扩展模拟post提交。参考代码
/** <br /> * Send a POST requst using cURL <br /> * @param string $url to request <br /> * @param array $post values to send <br /> * @param array $options for cURL <br /> * @return string <br /> */ <br />function curl_post($url, array $post = NULL, array $options = array()) <br />{ <br />    $defaults = array( <br />        CURLOPT_POST => 1, <br />        CURLOPT_HEADER => 0, <br />        CURLOPT_URL => $url, <br />        CURLOPT_FRESH_CONNECT => 1, <br />        CURLOPT_RETURNTRANSFER => 1, <br />        CURLOPT_FORBID_REUSE => 1, <br />        CURLOPT_TIMEOUT => 4, <br />        CURLOPT_POSTFIELDS => http_build_query($post) <br />    ); <br /><br />    $ch = curl_init(); <br />    curl_setopt_array($ch, ($options + $defaults)); <br />    if( ! $result = curl_exec($ch)) <br />    { <br />        trigger_error(curl_error($ch)); <br />    } <br />    curl_close($ch); <br />    return $result; <br />}
Copy after login
然后怎么调用呢?

$data = json_encode(array(你要发送的data数组));
$rs = curl_post("http://199.199.99.199:8080/cloudTVPlatform/external/api?act=notifyNewDeveloper&PID=CloudTVDN&pversion=1.0&format=JSON", $data);
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!