The two most promising have been:
<cfset tmp = {} />
<cfset tmp['Authorization'] = "Token token='MYKEYHERE'" />
<cfhttp url="https://api.callrail.com/v1/companies.json" result="r"
method="post" >
<cfhttpparam type="header" name="content-type" value="application/json" />
<!---<cfhttpparam type="body" value="#origTemp#" />--->
<cfhttpparam type="body" value="#serializeJson(tmp)#" />
</cfhttp>
<cfdump var="#r#" />
AND
<cfhttp url="https://api.callrail.com/v1/companies.json" result="r"
method="post" >
<cfhttpparam type="header" name="Authorization" value="Token token='
MYKEYHERE''" />
</cfhttp>
<cfdump var="#r#" />
Robert Harrison
Full Stack Developer
AIMG
[email protected]
Main Office: 704-321-1234 ext.121
Direct Line: 516-302-4345
www.aimg.com
-----Original Message-----
From: Dean Lawrence [mailto:[email protected]]
Sent: Monday, January 19, 2015 11:22 AM
To: cf-talk
Subject: Re: Call Rail API / CF
Robert, can you share the code that you have tried?
On Mon, Jan 19, 2015 at 9:31 AM, Robert Harrison <[email protected]> wrote:
>
> Below is a call rail API request in PHP. This works in PHP, but I need
> to run this in ColdFusion. I've tried every combination of cfhttp and
> cfhttpparam I can think of that looks correct, and have tried it using
> JSON, but I always get a 401 Unauthorized response. Anyone ever done
> the Call Rail API in CF or have any ideas on the code below. I'm about
> out of ideas.
>
>
>
> Thanks
>
>
>
>
>
> <?php
>
> $api_url = 'https://api.callrail.com/v1/companies.json';
>
>
>
> // Replace with your API Key
>
> $api_key = 'MYKEYHERE';
>
>
>
> $ch = curl_init($api_url);
>
>
>
> curl_setopt($ch, CURLOPT_HEADER, 0);
>
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
>
> curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Token
> token=\"{$api_key}\""));
>
>
>
> $json_data = curl_exec($ch);
>
> $parsed_data = json_decode($json_data);
>
> curl_close($ch);
>
>
>
> // Examine meta data from the response
>
> $total_entries = $parsed_data->total_entries;
>
> echo "Total entries: {$parsed_data->total_entries} \n";
>
>
>
> // Loop through companies
>
> foreach($parsed_data->companies as $company){
>
> echo "Company: {$company->name} \n";
>
> }
>
> ?>
>
>
>
>
>
>
>
>
>
> Robert Harrison
> Full Stack Developer
> AIMG
> <mailto:[email protected]> [email protected] Main Office:
> 704-321-1234 ext.121 Direct Line: 516-302-4345 <http://www.aimg.com/>
> www.aimg.com
>
>
>
>
>
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359995
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm