2017-09-25 2 views
0

Ich verwende den folgenden Code in meiner Wordpress-Site. und ich versuche, etwas von der Funktionalität zu ändern, indem ich den Webservice von wcf in meinem PHP-Code rufe. unten ist der Code, den ich verwende, die mir Fehler500 Interner Server Fehler bei der Verwendung von curl

$Url = "http://localhost:8080/Service1.svc/checkUseronHealnt"; 
$json = "[{\"MOBILE_NO\":\"8745009403,8745009411\"}]" 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $Url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json)); 
$curl_response = curl_exec($curl); 
if (curl_error($curl)) { 
    echo 'error:' . curl_error($curl); 
} else { 
    echo"Response - " . $curl_response; 
} 
+1

'$ json = "[{\" MOBILE_NO \ ": \" 8745009403,8745009411 \ "}]"' Semikolon nach dieser Zeile fehlt –

Antwort

0

$json = "[{\"MOBILE_NO\":\"8745009403,8745009411\"}]"
; fehlt, nachdem diese
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json));
json_encode benötigt wird hier nicht gibt.
Und es sei denn, es gibt { irgendwo über dem Code, den Sie zur Verfügung gestellt, letzte } wird auch nicht benötigt.

0

$ json = "[{\" MOBILE_NO \ ": \" 8745009403,8745009411 \ "}]" - Semikolon ist nach Aussage fehlt

entfernen zusätzliche geschweifte Klammer aus dem Code.

Ihr guter Code ist unter

$Url ="http://localhost:8080/Service1.svc/checkUseronHealnt"; 
$json = "[{\"MOBILE_NO\":\"8745009403,8745009411\"}]"; 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $Url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json)); 
$curl_response = curl_exec($curl); 
if(curl_error($curl)) { 
    echo 'error:' . curl_error($curl); 
} 
else { 
    echo"Response - ".$curl_response; 
}   
Verwandte Themen