1

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.

Jeromy French
  • 11,812
  • 19
  • 76
  • 129
Michael Giovanni Pumo
  • 14,338
  • 18
  • 91
  • 140

1 Answers1

7

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.

genericHCU
  • 4,394
  • 2
  • 22
  • 34
  • 1
    You are absolutely correct! Changing the type to 'formField' solved the bad request error. I have tried my code above and it now works brilliantly. I'll leave it all here to assist anyone else who may be a bit confused, like me. Thank you for your help. – Michael Giovanni Pumo Oct 30 '12 at 12:17
  • 1
    I don't suppose anyone has successfully passed the optional "scope" param in this call? I can't seem to pass "scope": "likes comments basic" and have the Access_Token returned with these permissions? appears to do nothing. – Phil Rasmussen Feb 22 '13 at 01:15