curl -F what does it mean? php instagram

笑着哭i 提交于 2019-12-23 18:09:53

问题


I'm trying to figure out what this means? I want to be able to post something to Instagram's API, but not sure what curl -F means? I tried searching it on google, but it's not giving me much. Maybe someone with this matter can shine some light?

Also, What is the best way to post to Instagram with this method? The documentation is asking

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

Can someone explain this to me?

Thanks in advance!


回答1:


curl is a linux utility that simulates web requests. Issuing a curl -F command issues a http request with form submission data. In this case, the form data is the data access_token=ACCESS-TOKEN and it is being issued to the url https://api.instagram.com/v1/media/{media-id}/likes

Further information on what cURL is and what it does can be found at http://curl.haxx.se/docs/manpage.html




回答2:


From 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.



回答3:


-F emulate user filling in a form and submit.

You can look for this in the man page of curl on your system. If it supports the option, it will have an entry in the man page.




回答4:


This isn't really a programming question but I can give you some guidance to help you on your way.

-F tells curl to emulate a filled in HTML Form that has just had it's submit button clicked.

Have a look at this page: http://curl.haxx.se/docs/manpage.html

And scroll down or search for the bit called

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

As that details it with more complexity



来源:https://stackoverflow.com/questions/10859374/curl-f-what-does-it-mean-php-instagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!