Re: Call Rail API / CF
If I were you I wouldn't get caught up in the example. There's a ruby one on their site that might make more sense to you, but to be honest a quick look at the APIs docs make it seem like it should be easy to do. http://apidocs.callrail.com/ curl is a command line tool correct? So you're either going to have to find another way to make the call or use cfexecute or write some java. Although I don't think you even need to do that or use curl. The methods and stuff look pretty easy to use all things considered though. I personally don't have the time to figure out some random API, at least not for free, and I doubt that anyone else does either. Now you want to throw down a little something... On Mon, Jan 19, 2015 at 9:31 AM, Robert Harrison rharri...@aimg.com 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:rharri...@aimg.com rharri...@aimg.com 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:359992 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
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 rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] 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 rharri...@aimg.com 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:rharri...@aimg.com rharri...@aimg.com 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
Re: Call Rail API / CF
You are more on track with the second one than the first. I have two comments. First, you are using a POST method and the documentation for the companies method states that it should be a GET method. Second, you are replacing MYKEYHERE with your assigned assigned API key, correct? On Mon, Jan 19, 2015 at 11:25 AM, Robert Harrison rharri...@aimg.com wrote: 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 rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -- [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:359996 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
I'm not using my key here... I just not posting my key to a public forum that's indexed in Google. And I've treid get also... I've tried every variation I can think of. I got a 200 response from GET but no data. Otherwise I get 401. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] Sent: Monday, January 19, 2015 11:31 AM To: cf-talk Subject: Re: Call Rail API / CF You are more on track with the second one than the first. I have two comments. First, you are using a POST method and the documentation for the companies method states that it should be a GET method. Second, you are replacing MYKEYHERE with your assigned assigned API key, correct? On Mon, Jan 19, 2015 at 11:25 AM, Robert Harrison rharri...@aimg.com wrote: 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 rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -- [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:359997 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
This line in the PHP seems to indicate that they are using double quotes around the key. curl_setopt($ch, CURLOPT_HTTPHEADER, array(Authorization: Token token=\{$api_key}\)); Have you tried using double quotes around the key? cfhttpparam type=header name=Authorization value='Token token=MYKEYHERE' / -- William Seiter -Original Message- From: Robert Harrison [mailto:rharri...@aimg.com] Sent: Monday, January 19, 2015 8:48 AM To: cf-talk Subject: RE: Call Rail API / CF Yes. The PHP version does pull the data. The CF version comes up empty. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] Sent: Monday, January 19, 2015 11:46 AM To: cf-talk Subject: Re: Call Rail API / CF Ok, good, I just wanted to make sure. So, when you use a GET, it sounds like you are authenticating correctly, no? This my sound stupid, but do you have any companies added to the system for the API to return? Also, have you tried removing the single quotes from your API key in the header? In the API documentation, it does not have quotes around it, Authorization: Token token=abc1234. On Mon, Jan 19, 2015 at 11:37 AM, Robert Harrison rharri...@aimg.com wrote: I'm not using my key here... I just not posting my key to a public forum that's indexed in Google. And I've treid get also... I've tried every variation I can think of. I got a 200 response from GET but no data. Otherwise I get 401. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:360002 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Call Rail API / CF
So when you dump the results of the cfhttp call, is it empty? If not, is there anything that is listed in the Filecontent key within the dump structure? On Mon, Jan 19, 2015 at 11:47 AM, Robert Harrison rharri...@aimg.com wrote: Yes. The PHP version does pull the data. The CF version comes up empty. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -- [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:36 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
Nada! Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] Sent: Monday, January 19, 2015 12:01 PM To: cf-talk Subject: Re: Call Rail API / CF So when you dump the results of the cfhttp call, is it empty? If not, is there anything that is listed in the Filecontent key within the dump structure? On Mon, Jan 19, 2015 at 11:47 AM, Robert Harrison rharri...@aimg.com wrote: Yes. The PHP version does pull the data. The CF version comes up empty. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -- [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:360001 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Call Rail API / CF
Ok, good, I just wanted to make sure. So, when you use a GET, it sounds like you are authenticating correctly, no? This my sound stupid, but do you have any companies added to the system for the API to return? Also, have you tried removing the single quotes from your API key in the header? In the API documentation, it does not have quotes around it, Authorization: Token token=abc1234. On Mon, Jan 19, 2015 at 11:37 AM, Robert Harrison rharri...@aimg.com wrote: I'm not using my key here... I just not posting my key to a public forum that's indexed in Google. And I've treid get also... I've tried every variation I can think of. I got a 200 response from GET but no data. Otherwise I get 401. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:359998 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
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 rharri...@aimg.com 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:rharri...@aimg.com rharri...@aimg.com 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:359994 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
Yes. The PHP version does pull the data. The CF version comes up empty. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] Sent: Monday, January 19, 2015 11:46 AM To: cf-talk Subject: Re: Call Rail API / CF Ok, good, I just wanted to make sure. So, when you use a GET, it sounds like you are authenticating correctly, no? This my sound stupid, but do you have any companies added to the system for the API to return? Also, have you tried removing the single quotes from your API key in the header? In the API documentation, it does not have quotes around it, Authorization: Token token=abc1234. On Mon, Jan 19, 2015 at 11:37 AM, Robert Harrison rharri...@aimg.com wrote: I'm not using my key here... I just not posting my key to a public forum that's indexed in Google. And I've treid get also... I've tried every variation I can think of. I got a 200 response from GET but no data. Otherwise I get 401. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:35 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Call Rail API / CF
Yep tried double quotes too. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: William Seiter [mailto:will...@seiter.com] Sent: Monday, January 19, 2015 12:06 PM To: cf-talk Subject: RE: Call Rail API / CF This line in the PHP seems to indicate that they are using double quotes around the key. curl_setopt($ch, CURLOPT_HTTPHEADER, array(Authorization: Token token=\{$api_key}\)); Have you tried using double quotes around the key? cfhttpparam type=header name=Authorization value='Token token=MYKEYHERE' / -- William Seiter -Original Message- From: Robert Harrison [mailto:rharri...@aimg.com] Sent: Monday, January 19, 2015 8:48 AM To: cf-talk Subject: RE: Call Rail API / CF Yes. The PHP version does pull the data. The CF version comes up empty. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Dean Lawrence [mailto:dean...@gmail.com] Sent: Monday, January 19, 2015 11:46 AM To: cf-talk Subject: Re: Call Rail API / CF Ok, good, I just wanted to make sure. So, when you use a GET, it sounds like you are authenticating correctly, no? This my sound stupid, but do you have any companies added to the system for the API to return? Also, have you tried removing the single quotes from your API key in the header? In the API documentation, it does not have quotes around it, Authorization: Token token=abc1234. On Mon, Jan 19, 2015 at 11:37 AM, Robert Harrison rharri...@aimg.com wrote: I'm not using my key here... I just not posting my key to a public forum that's indexed in Google. And I've treid get also... I've tried every variation I can think of. I got a 200 response from GET but no data. Otherwise I get 401. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:360003 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Call Rail API / CF
When I use this code, I get a result back. It is an unauthorized result since I don't have an API key, but it is a GET request and does return a JSON result. cfset api_url = https://api.callrail.com/v1/companies.json; / !---Replace with your API Key--- cfset api_key = MYKEYHERE / cfhttp method=get url=#api_url# result=json_data cfhttpparam type=header name=Authorization value=Token token=#api_key# /cfhttp cfdump var=#json_data# On Mon, Jan 19, 2015 at 12:07 PM, Robert Harrison rharri...@aimg.com wrote: Yep tried double quotes too. Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.121 Direct Line: 516-302-4345 www.aimg.com -- [image: profile picture] *Dean Lawrence* *President* Internet Data Technology *Phone:* 888-438-4381 x701 *Web:* www.idatatech.com *Email:* d...@idatatech.com Programming | Database | Consulting | Training ~| 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:360004 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm