【问题标题】:What does "curl" mean?“卷曲”是什么意思?
【发布时间】:2012-04-02 16:15:34
【问题描述】:

我每天都在开发 Facebook JavaScript 应用程序,但在 Facebook 文档和我访问的其他网站上不断遇到一些我不理解的代码 sn-ps。

我在 Google 上搜索了 CURL,并找到了一些关于它的描述。我不知道 Facebook 希望我如何使用它。

curl -F "title=Example Title" -F "description=Description" \
-F "start_time=1329417443" \
"https://graph.facebook.com/PAGE_ID/milestones?access_token=_"

这对我来说是无稽之谈。您能否帮助我了解我可以在什么情况下将它用于 Facebook 以及一般情况下,并指导我在正确的方向上找到有关该主题的更多信息?

【问题讨论】:

标签: javascript facebook curl


【解决方案1】:

curl 是一个命令行实用程序,可让您发送 HTTP 请求。它对于使用 Web 服务 API 进行开发非常有用。我相信大多数 linux 发行版都预装了它,但你需要为 Windows 下载并安装它。 (它可能与 Cygwin 一起提供,但也可以单独安装。)

我建议确保将其目录添加到您的 PATH 环境变量中。同样,在 linux 中可能不是问题,但您需要在 windows 中手动执行此操作。

【讨论】:

    【解决方案2】:

    curl 是一个获取请求的命令。 -F (--form) 参数用于指定表单 POST 参数。

    来自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.
    

    【讨论】:

    • 附言。我虽然很明显curl 的最后一个参数是提交表单的位置。添加此注释,以防万一。
    【解决方案3】:
    【解决方案4】:

    当然,FB 文档使用 curl 来展示执行请求的通用基本方式...这取决于您使用什么平台语言库来执行图形 http 请求的实际方式

    ...如果你是 Facebook JavaScript 开发者,你必须使用 XMLHttpRequest(或者我想是 facebook js lib 调用)

    【讨论】:

      猜你喜欢
      • 2013-03-14
      • 1970-01-01
      • 2016-11-11
      • 2021-06-15
      • 1970-01-01
      • 2012-11-20
      • 2018-04-28
      • 1970-01-01
      • 2011-08-12
      相关资源
      最近更新 更多