<bdo id='i7Ev7'></bdo><ul id='i7Ev7'></ul>

  • <small id='i7Ev7'></small><noframes id='i7Ev7'>

    1. <tfoot id='i7Ev7'></tfoot>
    2. <legend id='i7Ev7'><style id='i7Ev7'><dir id='i7Ev7'><q id='i7Ev7'></q></dir></style></legend>

      1. <i id='i7Ev7'><tr id='i7Ev7'><dt id='i7Ev7'><q id='i7Ev7'><span id='i7Ev7'><b id='i7Ev7'><form id='i7Ev7'><ins id='i7Ev7'></ins><ul id='i7Ev7'></ul><sub id='i7Ev7'></sub></form><legend id='i7Ev7'></legend><bdo id='i7Ev7'><pre id='i7Ev7'><center id='i7Ev7'></center></pre></bdo></b><th id='i7Ev7'></th></span></q></dt></tr></i><div id='i7Ev7'><tfoot id='i7Ev7'></tfoot><dl id='i7Ev7'><fieldset id='i7Ev7'></fieldset></dl></div>

        无法将 POST curl 从命令行转换为 php

        Trouble converting POST curl from command line to php(无法将 POST curl 从命令行转换为 php)
        <tfoot id='zDtSb'></tfoot>
        1. <small id='zDtSb'></small><noframes id='zDtSb'>

          • <i id='zDtSb'><tr id='zDtSb'><dt id='zDtSb'><q id='zDtSb'><span id='zDtSb'><b id='zDtSb'><form id='zDtSb'><ins id='zDtSb'></ins><ul id='zDtSb'></ul><sub id='zDtSb'></sub></form><legend id='zDtSb'></legend><bdo id='zDtSb'><pre id='zDtSb'><center id='zDtSb'></center></pre></bdo></b><th id='zDtSb'></th></span></q></dt></tr></i><div id='zDtSb'><tfoot id='zDtSb'></tfoot><dl id='zDtSb'><fieldset id='zDtSb'></fieldset></dl></div>
            • <bdo id='zDtSb'></bdo><ul id='zDtSb'></ul>

              <legend id='zDtSb'><style id='zDtSb'><dir id='zDtSb'><q id='zDtSb'></q></dir></style></legend>

                  <tbody id='zDtSb'></tbody>

                  本文介绍了无法将 POST curl 从命令行转换为 php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在将 curl 命令转换为 php 时遇到问题.

                  I am having trouble converting my curl command into php.

                  这部分效果很好.

                  将条目添加到 Parse.com 数据库的 CURL 命令:

                  CURL command that adds an entry into my Parse.com database:

                  curl -X POST 
                    -H "X-Parse-Application-Id: my_id" 
                    -H "X-Parse-REST-API-Key: api_id" 
                    -H "Content-Type: application/json" 
                    -d "{"SiteID":"foundID","dataUsedString":"foundUsage","usageDate":"foundDate", "monthString":"foundMonth", "dayString":"foundDay","yearString":"foundYear"}" 
                    https://api.parse.com/1/classes/MyClass
                  

                  已解决的答案:

                  我创建了这个 php 脚本来复制命令:

                  I have created this php script to replicate the command:

                     <?php 
                     $ch = curl_init('https://api.parse.com/1/classes/MyClass');
                  
                  curl_setopt($ch,CURLOPT_HTTPHEADER,
                      array('X-Parse-Application-Id:my_id',
                  'X-Parse-REST-API-Key:api_id',
                  'Content-Type: application/json'));
                  
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  curl_setopt($ch, CURLOPT_POST, 1);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, "{"SiteID":"foundID","dataUsedString":"foundUsage","usageDate":"foundDate", "monthString":"foundMonth", "dayString":"foundDay","yearString":"foundYear"}");
                  
                  curl_exec($ch);
                  curl_close($ch);
                  ?>
                  

                  推荐答案

                  您错过了一些重要的配置.这些是设置 CURL 以使用 POST 发送请求,第二个是要发送的数据.(原始数据作为字符串发送到 POSTFIELDS,如果你发送数组 - 它会自动附加标题multipart/form-data"

                  You've missed some crucial configurations. These are the set the CURL to send request using POST, and the second is data to send. (RAW DATA is being sent as string into POSTFIELDS, those if you send array - it will automatically append header "multipart/form-data"

                  $ch = curl_init('https://api.parse.com/1/classes/MyClass');
                  
                  curl_setopt($ch,CURLOPT_HTTPHEADER,
                    array(
                      'X-Parse-Application-Id:my_id',
                      'X-Parse-REST-API-Key:api_id',
                      'Content-Type: application/json'
                    )
                  );
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  curl_setopt($ch, CURLOPT_POST, 1);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, "{"SiteID":"foundID","dataUsedString":"foundUsage","usageDate":"foundDate", "monthString":"foundMonth", "dayString":"foundDay","yearString":"foundYear"}");
                  curl_exec($ch);
                  curl_close($ch);
                  

                  HTH:)

                  这篇关于无法将 POST curl 从命令行转换为 php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Proxy Authentication Required with cURL(cURL 需要代理身份验证)
                  How to use a SOCKS 5 proxy with cURL?(如何使用带有 cURL 的 SOCKS 5 代理?)
                  How to use HTTP_X_FORWARDED_FOR properly?(如何正确使用 HTTP_X_FORWARDED_FOR?)
                  file_get_contents behind a proxy?(代理后面的 file_get_contents ?)
                  pecl install cassandra throws: quot;error: Unable to load libcassandraquot;(pecl install cassandra 抛出:“错误:无法加载 libcassandra)
                  Installing php datastax driver on ubuntu(在 ubuntu 上安装 php datastax 驱动)
                  • <small id='9zVhh'></small><noframes id='9zVhh'>

                      <bdo id='9zVhh'></bdo><ul id='9zVhh'></ul>
                        • <i id='9zVhh'><tr id='9zVhh'><dt id='9zVhh'><q id='9zVhh'><span id='9zVhh'><b id='9zVhh'><form id='9zVhh'><ins id='9zVhh'></ins><ul id='9zVhh'></ul><sub id='9zVhh'></sub></form><legend id='9zVhh'></legend><bdo id='9zVhh'><pre id='9zVhh'><center id='9zVhh'></center></pre></bdo></b><th id='9zVhh'></th></span></q></dt></tr></i><div id='9zVhh'><tfoot id='9zVhh'></tfoot><dl id='9zVhh'><fieldset id='9zVhh'></fieldset></dl></div>
                          1. <tfoot id='9zVhh'></tfoot>
                              <tbody id='9zVhh'></tbody>

                            <legend id='9zVhh'><style id='9zVhh'><dir id='9zVhh'><q id='9zVhh'></q></dir></style></legend>