Skip to main content
Inspiring
July 28, 2010
Answered

JSON call - PHP to CFML translation

  • July 28, 2010
  • 1 reply
  • 1762 views

Hi all,

I am working on communicating to an api of a domain register, now i found the following code that is voor php:

$domain = "test.nl";
$params = array();
$request_url = "https://httpapi.yoursrs.com/v1/domains/" . urlencode($domain) . "/check";
$response = sendRequest($request_url, $params, "tester", "pass1234");
print_r($response);

Now i need to change this to cfml code and i tried:

<cfset jsondata = {
login_handle = "username",
login_pass = "password"
} />

<cfhttp
url="https://httpapi.yoursrs.com/v1/domains/test.nl/check"
method="post"
result="result">

#SerializeJSON(jsondata)#  

</cfhttp>

Still i have no luck, does anyone can translate that php to cfml?

This topic has been closed for replies.
Correct answer -__cfSearching__-

$response = sendRequest($request_url, $params, "tester",

"pass1234");

A quick google search suggests sendRequest is not a standard php function. What does the sendRequest function do and how is json involved ...?

1 reply

-__cfSearching__-Correct answer
Inspiring
July 28, 2010

$response = sendRequest($request_url, $params, "tester",

"pass1234");

A quick google search suggests sendRequest is not a standard php function. What does the sendRequest function do and how is json involved ...?

Inspiring
July 28, 2010

From the API doc this is the code how it should be used:

Request


Method: POST
URL: https://httpapi.yoursrs.com/v1/domains/example.com/check
BODY:
{
"login_handle":"example_user",
"login_pass":"********"
}


Response


{
"command":"domain:check",
"handle":"example.com",
"code":1000,
"msg":"Command completed successfully",
"error":[
],
"params":{
"handle":"example.com"
},
"svTRID":"158759-2-yoursrs",
"response":{
"avail":"0"
}
}

So this JSON markup needs to be placed inside the body of the post request.

Any idea's? Or examples somewhere?

I can find pieces of info around the net but nowhere a full example...

Inspiring
July 28, 2010

Try using cfhttpparam type="body"

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_g-h_10.html