Curl call to ColdFusion - Instagram

岁酱吖の 提交于 2019-12-24 08:49:27

问题


I'm not experienced with cURL at all, but from what I can gather, it's equivalent to cfhttp.

I want to work with the Instagram API and authenticate a user. Their example uses cURL.

curl \-F 'client_id=CLIENT-ID' \
    -F 'client_secret=CLIENT-SECRET' \
    -F 'grant_type=authorization_code' \
    -F 'redirect_uri=YOUR-REDIRECT-URI' \
    -F 'code=CODE' \https://api.instagram.com/oauth/access_token

Would I be correct in thinking the CF version would be:

<cfhttp url="https://api.instagram.com/oauth/access_token" method="post" resolveurl="true">
    <cfhttpparam type="formField" name="client_id" value="CLIENT-ID" />
    <cfhttpparam type="formField" name="client_secret" value="CLIENT-SECRET" />
    <cfhttpparam type="formField" name="grant_type" value="authorization_code" />
    <cfhttpparam type="formField" name="redirect_uri" value="YOUR-REDIRECT-URI" />
    <cfhttpparam type="formField" name="code" value="code" />
</cfhttp>

I'm not able to try this yet as I won't be at my development machine until a lot later, so I'm just digging around right now looking at possibilities and making pseudo-code (not tested!).

Anyone with specific experience with the Instagram API and ColdFusion who could shed some insight would be greatly appreciated.

I'm using Railo.


回答1:


According to how to use cURL the -F option is form data.

http://curl.haxx.se/docs/manpage.html

So you're going to want to send form data, not url data in your cfhttpparam tags.

<cfhttp url="https://api.instagram.com/oauth/access_token" method="post" resolveurl="true">
    <cfhttpparam type="formField" name="client_id" value="CLIENT-ID" />
    <cfhttpparam type="formField" name="client_secret" value="CLIENT-SECRET" />
    <cfhttpparam type="formField" name="grant_type" value="authorization_code" />
    <cfhttpparam type="formField" name="redirect_uri" value="YOUR-REDIRECT-URI" />
    <cfhttpparam type="formField" name="code" value="code" />
</cfhttp>

I don't know anything about the Instagram API and only what I read in the above link about cURL so this may not be the complete solution but it looks like you're on the right track.



来源:https://stackoverflow.com/questions/13138365/curl-call-to-coldfusion-instagram

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