2016-10-02 82 views
-1

您好,所以我试图使用Freenom API来实现名为iForce的服务,为人们注册域名非常容易,并且我发现了这个cURL命令,但我不知道如何让PHP运行它。PHP中的cURL命令

以下是命令

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

如果有人能请将其转换成PHP或告诉我如何或告诉我如何使用它在PHP这将是惊人的!

非常感谢!

+1

[用PHP执行Curl]的可能副本(http://stackoverflow.com/questions/14899037/executing-curl-with-php) –

+1

http://php.net/manual/en/book.curl。 php –

回答

-1

喜欢的东西:

<?php 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL,"https://api.freenom.com/v2/domain/search.xml?domainname=test001.tk&[email protected]&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); 

?> 

现在你可以使用$server_output您的需求。

+1

除非你绝对知道你在做什么,否则你不应该关闭对等验证。在大多数情况下,你不会。 – Terry

+0

确实,我添加它的唯一原因是导致HTTPS协议上最开放的API,如果验证为“真”,则会返回失败的请求。我不知道为什么。 – Anuga

+1

这可能是因为您在本地主机上运行,​​或者在[没有正确设置证书的服务器上运行](https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-修复 - 你的PHP-配置/)。正确的解决方案是修复证书 - 不要关闭证书验证。 – Terry