简体   繁体   中英

how to convert the instagram curl post request to javascript request?

I'm trying to change the code i got from Instagram to a token. In Instagram DOCS it is writes with a curl request and i want to use JavaScript. its look like this:

curl -X POST \
  https://api.instagram.com/oauth/access_token \
  -F client_id={app-id} \
  -F client_secret={app-secret} \
  -F grant_type=authorization_code \
  -F redirect_uri={redirect-uri} \
  -F code={code}

I'm trying to understand what is -F and with what symbol to replace it.

Any solution will help, thank you.

-F is for emulating html form submission https://curl.se/docs/manpage.html#-F

if you want to sent the request using JavaScript fetch() API, set all those parameters as body of request and set the content type to application/x-www-form-urlencoded

if you are sending these requests interactively, alternatively you can create an HTML page with a form and submit button.( eg https://www.w3schools.com/tags/att_form_enctype.asp )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM