当我尝试在laravel代码中使用ovh API创建子域时,我得到了这个错误。
POST https://eu.api.ovh.com/1.0/domain/zone/mondomain.com/record resulted in a 400 Bad Request response: {"message":"Invalid signature","httpCode":"400 Bad Request","errorCode":"INVALID_SIGNATURE"}我的PHP代码如下所示:
$ovh = new Api(
$applicationKey, // Application Key
$applicationSecret, // Application Secret
'ovh-eu', // Endpoint of API OVH Europe (List of available endpoints)
$consumerKey
); // Consumer Key
$result = $ovh->post(
'/domain/zone/mondomain.com/record',
array(
'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
'target' => 'monIP', // Resource record target (type: string) ssh root@
'ttl' => '0', // Resource record ttl (type: long)
)
);
return $result;谢谢你的帮助。
发布于 2021-02-05 21:52:17
INVALID_SIGNATURE表示缺少某些参数或某些值与请求的参数类型(string、long等)不匹配。
在您的例子中,参数ttl需要是一个long,但是您给了它一个string。
它应该更好地使用:
$result = $ovh->post('/domain/zone/mondomain.com/record', array(
'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
'target' => 'monIP', // Resource record target (type: string) ssh root@
'ttl' => 0, // Resource record ttl (type: long)
));这里唯一的区别是'0'和0 (没有简单的引号)
签名可以在这里找到:
如果您通过此接口控制台执行请求,在Raw选项卡中可以看到生成的请求:
{
"fieldType": "A",
"subDomain": "test-sousdomain",
"target": "monIp",
"ttl": 0
}发布于 2021-05-22 22:37:36
$result = $ovh->post('/domain/zone/mondomain.com/record', array(
'fieldType' => 'A', // Resource record Name (type: zone.NamedResolutionFieldTypeEnum)
'subDomain' => 'test-sousdomain', // Resource record subdomain (type: string)
'target' => 'monIP', // Resource record target (type: string) ssh root@
'ttl' => 0, // Resource record ttl (type: long)
));zone.NamedResolutionFieldTypeEnum:
这应该返回可用字段类型的列表。它的返回值是一个整数。
您正在将'A'作为字符串传递。我建议您将其更改为。
https://stackoverflow.com/questions/66061092
复制相似问题