2017-04-18 6 views
-1

Fehlerunerwarteter Token Fehler bei der Integration godaddy Domäne API

{ "message": "Unexpected token‚", "body":" { 'Typ': 'A', 'Name': ' tarunDhiman‘, 'Daten': '166.62.81.221', 'ttl': 3600}"}

-Code

$data = "{'type':'A','name':'tarunDhiman','data':'166.62.81.221','ttl':3600}"; 

$url = "https://api.godaddy.com/v1/domains/{domain}/records"; 

$headers = array(
    'Content-Type: application/json', 
    'Accept : application/json', 
    'Authorization : sso-key {key}:{token}'); 

$curl = curl_init(); 

curl_setopt($curl, CURLOPT_URL, $url); 

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH'); 

curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 

$response = curl_exec($curl); 

curl_close($curl); 
print $response ; 
exit; 

Antwort

0

Das Problem mit Hilfe von @ Slaiv206 gelöst Und unter dem Arbeitscode.

$data = '[{ "type":"A", "name":"tarunDhiman", "data":"255.255.255.0", "ttl":3600 }]'; 
 

 
$url = "https://api.godaddy.com/v1/domains/{domain}/records"; 
 

 
$headers = array(
 
\t 'Content-Type: application/json', 
 
\t 'Accept : application/json', 
 
\t 'Authorization : sso-key {key}:{secret}'); 
 

 
$curl = curl_init(); 
 

 
curl_setopt($curl, CURLOPT_URL, $url); 
 

 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
 

 
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH'); 
 

 
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
 

 
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 
 

 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
 

 
$response = curl_exec($curl); 
 

 
curl_close($curl); 
 
print $response ; 
 
exit;

0

ich denke, die strin Header Authorization g ist:

Authorization: sso-key {KEY}:{SECRET} 

und nicht:

Authorization : sso-key {key}:{token} 

und in dem JSON-String doppelte Anführungszeichen statt einfache Anführungszeichen verwenden:

'{ "type":"A", "name":"tarunDhiman", "data":"166.62.81.221", "ttl":3600 }' 
+0

ja sind Sie richtig, aber es funktioniert nicht .. :( –

+0

und in der JSON-String doppelte Anführungszeichen statt einfache Anführungszeichen verwenden: { "type": "A", " name ":" tarunDhiman ", " daten ":" 166.62.81.221 ", " ttl ": 3600 } – Slaiv206

+0

Bei Verwendung von '{" type ":" A "," name ":" tarunDhiman "," data " : "166.62.81.221", "ttl": 3600} ', doppelte Anführungszeichen unter dem Fehler {"code": "INVALID_BODY", "message ":" Request Body erfüllt das Schema nicht, siehe Details in 'fields'", "responseModel": "Fehler", "fields": [{"message": "ist kein Array", "path": "records "," code ":" UNEXPECTED_TYPE "}]} –

Verwandte Themen