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:
[i]
[function.file-get-contents]: failed to open stream: No such file or directory in /home/xyz/public_html/dynadotdomainsearch.php on line 10[/i]
The line of code referred to above is as follows:
[b]$answer = file_get_contents("https://www.dynadot.com/api.html?
version=1.0&key=".$key."&command=search&domain0=mydomain.net");[/b]
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:
[color=#3333FF]$answer = file_get_contents("http://www.google.com");
echo $answer;[/color]
^ 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.]
Posted By kate07/20/2007 19:04
kate replied kewlceo
Instead of file_get_contents you should use fopen or better yet use Curl with PHP as you have more control.
Reply Quote
Like
0 Replies
Posted By kewlceo07/20/2007 21:21
kewlceo replied kewlceo
Thank you, Kate!
[color=#3333FF]
$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);
[/color]
Best,
Rick
[This post has been edited by kewlceo on Jul 20, 2007 2:23pm.]
Reply Quote
Like
0 Replies
Posted By achioo08/23/2007 15:56
achioo replied kewlceo
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.
Dynadot API question