php - GoDaddy API - 批量域查询 php
问题描述
我正在尝试使用 php 和 curl 查询多个域名的可用性,但我似乎无法得到有效的响应。
API: https ://api.godaddy.com/v1/domains/available
此处的文档: https ://developer.godaddy.com/doc/endpoint/domains#/v1/availableBulk
我的代码如下。任何帮助将非常感激。
$domains = array("name.com", "test.com", "monkey123er.com", "Sally123.co");
$domainsJSON = json_encode($domains);
// see GoDaddy API documentation - https://developer.godaddy.com/doc
// url to check domain availability
$url = "https://api.godaddy.com/v1/domains/available".
// see GoDaddy API documentation - https://developer.godaddy.com/doc
// set your key and secret
$header = array(
'Authorization: sso-key XXX:XXXX'
);
//open connection
$ch = curl_init();
$timeout=60;
//set the url and other options for curl
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // Values: GET, POST, PUT, DELETE, PATCH, UPDATE
curl_setopt($ch, CURLOPT_POSTFIELDS, $domainsJSON);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//execute post and return response data.
$result = curl_exec($ch);
//close curl connection
curl_close($ch);
// decode the json response
$dn = json_decode($result, true);
echo '<pre>'; print_r($dn); echo '</pre>';
解决方案
推荐阅读
- java - 使用正则表达式在部分内的组件中搜索数字
- rotation - 在画布中多次旋转单行
- windows - rm --cached 后无法阻止 git 修改文件
- qt - Clion 不会索引自动生成的 ui 头文件
- node.js - 如何在 Firebase 中获取 service-account.json 以获取 signedURL?
- python - 未定义 Django 项目全局名称“用户”
- azure - 我可以使用 Graph API 和 ADAL 库将 Azure 工作场所加入设备状态更改为合规性吗
- .htaccess - .htaccess:将特定链接重定向到另一个?
- scala - 在 spark scala 中保存 Xgboost 模型的问题
- cluster-analysis - 3个时间序列之间的聚类矩阵距离