How do I use PHP to send curl instructions?

Source: Internet
Author: User
Curl https://xxx.com/manage/json-rpc/xxxxxxx--header ' xxxxcxxxx-api-key:00000000 '--data ' {"JSONRPC": "2.0", "id": 1, "Method": "Push.send", "params": {"Pushprojectid": "XXXXXXX", "Platform": "ios", "Target": "Debugger", "BuildType": " Debug "," "Message": "Manage Sample", "JSON": "{\" url\ ": \" Http://www.baidu.com\ "}", "Deviceidlist": ["DDDDDDDDDDDDDDD"] }}'

如何利用PHP发送这条curl指令? 网上研究了半天毫无进展

Reply content:

Curl https://xxx.com/manage/json-rpc/xxxxxxx--header ' xxxxcxxxx-api-key:00000000 '--data ' {"JSONRPC": "2.0", "id": 1, "Method": "Push.send", "params": {"Pushprojectid": "XXXXXXX", "Platform": "ios", "Target": "Debugger", "BuildType": " Debug "," "Message": "Manage Sample", "JSON": "{\" url\ ": \" Http://www.baidu.com\ "}", "Deviceidlist": ["DDDDDDDDDDDDDDD"] }}'

如何利用PHP发送这条curl指令? 网上研究了半天毫无进展

First of all, I think your --data content should be wrong.
Then you either use it directly exec : http://php.net/manual/zh/function.exec.php

Or simply use PHP's CURL library: http://php.net/manual/zh/function.curl-setopt.php

$curl = curl_init('https://xxx.com/manage/json-rpc/xxxxxxx');curl_setopt( $curl, CURLOPT_HTTPHEADER, array("xxxxcxxxx-API-Key: 00000000") );curl_setopt( $curl, CURLOPT_POSTFILESD, array( "jsonrpc" => "2.0" ) );curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true);$res = curl_exec( $curl );curl_close( $curl );
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.