【问题标题】:How do i post multipart/form-data that contain symbol我如何发布包含符号的多部分/表单数据
【发布时间】:2009-09-18 18:19:32
【问题描述】:

这让我头痛了好几个小时,我尝试使用 curl 使用我的 Twitter 帐户将图像发布到 twitpic。

curl -F "username=myusername" -F "password=='hwsh[g" -F "message=test twitpic" -F media=@/dos/smallapps2/smallapps/tiny-delicious/snapshot/test.png http: //twitpic.com/api/uploadAndPost

它总是返回

   <?xml version="1.0" encoding="UTF-8"?>
    <rsp stat="fail">
        <err code="1001" msg="Invalid twitter username or password" />
    </rsp>

但是当我将推特密码更改为简单的单词时(不包含“=”、“-”、“[”) 没关系

<?xml version="1.0" encoding="UTF-8"?>
<rsp status="ok">
 <statusid>4084106555</statusid>
 <userid>33348202</userid>
 <mediaid>56qrz</mediaid>
 <mediaurl>http://twitpic.com/i6qwg</mediaurl>
</rsp>

我的问题是如何使用包含任何字符的强密码来执行此操作。 请提示。 谢谢。

【问题讨论】:

    标签: linux curl multipartform-data


    【解决方案1】:

    我尝试使用完全相同的密码(在测试帐户上)运行您的示例,并且上传我的示例图像没有任何问题。我什至查看了 pcap 以确保编码正确完成。

    -desktop:~/Dropbox$ curl -vv -F "username=********" -F "password=='hwsh[g" -F "message=test twitpic" -F media=@./code_Quality_Measurement_wtfm.jpg  http://twitpic.com/api/uploadAndPost
    * About to connect() to twitpic.com port 80 (#0)
    *   Trying 174.36.58.233... connected
    * Connected to twitpic.com (174.36.58.233) port 80 (#0)
    > POST /api/uploadAndPost HTTP/1.1
    > User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
    > Host: twitpic.com
    > Accept: */*
    > Content-Length: 46066
    > Expect: 100-continue
    > Content-Type: multipart/form-data; boundary=----------------------------50b761e49108
    >
    < HTTP/1.1 100 Continue
    < HTTP/1.1 200 OK
    < Server: nginx/0.6.35
    < Date: Thu, 03 Dec 2009 19:06:38 GMT
    < Content-Type: application/xml
    < Connection: keep-alive
    < X-Powered-By: PHP/5.2.9
    < Content-Length: 196
    <
    <?xml version="1.0" encoding="UTF-8"?>
    <rsp status="ok">
     <statusid>6311967029</statusid>
     <userid>**********</userid>
     <mediaid>rzu6c</mediaid>
     <mediaurl>http://twitpic.com/rzu6c</mediaurl>
    * Connection #0 to host twitpic.com left intact
    * Closing connection #0
    </rsp>
    

    你用的是什么外壳?根据您在密码中使用的“特殊”字符,您可能需要对它们进行不同的转义以防止 shell 扩展/etc

    任何时候你在命令行中使用双引号,你都必须处理变量扩展,特别是如果你的密码包含一个美元符号 ($)。最好在密码字段周围使用单引号,并明确转义密码中的任何单引号:

    -F 'password==\'hwsh[g'
    

    【讨论】:

      猜你喜欢
      • 2015-10-31
      • 1970-01-01
      • 2016-02-12
      • 1970-01-01
      • 2016-11-08
      • 2016-05-13
      • 1970-01-01
      • 2019-11-19
      相关资源
      最近更新 更多