Are you sure you want to close the chat?Chat will be closed and the chat history will be cleared.
continue to sign out,
or stay on chat.
To review this chat session please click this windows.
Chat Online
Chat Online0
Support

Forum

A place for Dynadot and community experts alike to ask questions, share ideas, and more.
Dynadot API question
7/20/2007 08:23
I'm trying to get a script working with the Dynadot API, but when I do a domain name search here's what I get:

[function.file-get-contents]: failed to open stream: No such file or directory in /home/xyz/public_html/dynadotdomainsearch.php on line 10


The line of code referred to above is as follows:

$answer = file_get_contents("https://www.dynadot.com/api.html?
version=1.0&key=".$key."&command=search&domain0=mydomain.net");


I made sure that my key and the command line itself works properly by entering it directly into my browser address line. Doing it that way, I get back the proper response. I just can't get it programmatically. I also made sure that I my IP addy was correct in my Dynadot API panel, and that this function is supported on my server, by testing the same code like so:

$answer = file_get_contents("http://www.google.com");
echo $answer;


^ This works fine, so now I'm stumped. Any ideas?

Thanks,
Rick


[This post has been edited by kewlceo on Jul 20, 2007 8:24am.]
Reply Quote
Posted By achioo
8/23/2007 08:56
Suggestion... kewlceo... change your code from


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.dynadot.com/api.html?version=1.0&key=".$key."&command=search&domain0=mydomain.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

to


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.dynadot.com/api.html?version=1.0&key=".$key."&command=search&domain0=mydomain.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);

The reason for the change is that when you run curl_exec now it will return the page a string rather than trying to output it automatically allowing you to play around with it more and to customize it.
Reply Quote
7/20/2007 14:21
Thank you, Kate!

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.dynadot.com/api.html?version=1.0&key=".$key."&command=search&domain0=mydomain.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);


Best,
Rick


[This post has been edited by kewlceo on Jul 20, 2007 2:23pm.]
Reply Quote
Posted By kate
7/20/2007 12:04
Instead of file_get_contents you should use fopen or better yet use Curl with PHP as you have more control.
Reply Quote