【问题标题】:curl -F what does it mean? php instagramcurl -F 是什么意思? php instagram
【发布时间】:2012-06-02 02:34:56
【问题描述】:

我想弄清楚这意味着什么?我希望能够向 Instagram 的 API 发布一些内容,但不确定 curl -F 是什么意思?我尝试在谷歌上搜索它,但它并没有给我太多。也许有这件事的人可以发光?

另外,使用这种方法发布到 Instagram 的最佳方式是什么?文档在问

curl -F 'access_token=ACCESS-TOKEN' \
    https://api.instagram.com/v1/media/{media-id}/likes

谁能给我解释一下?

提前致谢!

【问题讨论】:

    标签: php api post curl instagram


    【解决方案1】:

    来自man curl

       -F, --form <name=content>
              (HTTP) This lets curl emulate a filled-in form in
              which a user has pressed the submit button. This
              causes curl to POST data using the Content-Type
              multipart/form-data according to RFC 2388. This
              enables uploading of binary files etc. To force the
              'content' part to be a file, prefix the file name with
              an @ sign. To just get the content part from a file,
              prefix the file name with the symbol <. The difference
              between @ and < is then that @ makes a file get
              attached in the post as a file upload, while the <
              makes a text field and just get the contents for that
              text field from a file.
    
              Example, to send your password file to the server,
              where 'password' is the name of the form-field to
              which /etc/passwd will be the input:
    
              curl -F password=@/etc/passwd www.mypasswords.com
    
              To read content from stdin instead of a file, use - as
              the filename. This goes for both @ and < constructs.
    
              You can also tell curl what Content-Type to use by
              using 'type=', in a manner similar to:
    
              curl -F "web=@index.html;type=text/html" url.com
    
              or
    
              curl -F "name=daniel;type=text/foo" url.com
    
              You can also explicitly change the name field of a
              file upload part by setting filename=, like this:
    
              curl -F "file=@localfile;filename=nameinpost" url.com
    
              See further examples and details in the MANUAL.
    
              This option can be used multiple times.
    

    【讨论】:

      【解决方案2】:

      curl 是一个模拟 Web 请求的 linux 实用程序。发出curl -F 命令发出带有表单提交数据的http 请求。在这种情况下,表单数据是数据access_token=ACCESS-TOKEN,它被发送到url https://api.instagram.com/v1/media/{media-id}/likes

      有关 cURL 是什么以及它的作用的更多信息,请访问http://curl.haxx.se/docs/manpage.html

      【讨论】:

        【解决方案3】:

        -F模拟用户填写表单并提交。

        您可以在系统上的 curl 手册页中查找此内容。如果它支持该选项,它将在手册页中有一个条目。

        【讨论】:

          【解决方案4】:

          这不是一个真正的编程问题,但我可以为您提供一些指导以帮助您。

          -F 告诉 curl 模拟一个填写好的 HTML 表单,该表单刚刚点击了提交按钮。

          看看这个页面:http://curl.haxx.se/docs/manpage.html

          然后向下滚动或搜索名为

          的位
          '-F, --form <name=content>'
          

          因为它更复杂地详细说明了它

          【讨论】:

            猜你喜欢
            • 2018-11-24
            • 2020-03-03
            • 1970-01-01
            • 2014-06-18
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多