-1

Hi there so i am trying to use the Freenom API for a service called iForce to register domain names for people really easily and i came accross this cURL command but i have no idea how to make PHP run it.

The following is the command

 curl -X GET "https://api.freenom.com/v2/domain/search.xml\
    ?domainname=test001.tk\
    &email=john@smith.net\
    &password=68bb651cb1\
    &domaintype=PAID"

If someone could please convert that to php or tell me how to or tell me how to use it in php that would be amazing!

Thank you so so much!

1 Answers1

-1

Something like:

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://api.freenom.com/v2/domain/search.xml?domainname=test001.tk&email=john@smith.net&password=68bb651cb1&domaintype=PAID");
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Try it on true first, if that fails, set it back to false.

$server_output = curl_exec($ch);

curl_close ($ch);

?>

Now you can use $server_output for your needs.

Anuga
  • 2,619
  • 1
  • 18
  • 27
  • 1
    You should NOT turn off peer verification unless you absolutely know what you're doing. In most cases you don't. – Terry Oct 02 '16 at 22:33
  • True, the only reason I added it, is cause most open API's on HTTPS protocol, will return a failed request if verification is `true`. I don't know why. – Anuga Oct 02 '16 at 22:35
  • 1
    That's likely because you're running on localhost, or on a server that [do not have certificates properly set up](https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/). The correct solution is to fix the certificates—not turn off certificate verification. – Terry Oct 02 '16 at 22:36