0
我試圖讓與Magento的剩餘2 API的身份驗證令牌與下面的代碼PHP捲曲REST API令牌返回假的Magento 2
$userData = array("username" => "user", "password" => "password");
$ch = curl_init("https://domain/index.php/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
var_dump($token);
它工作正常,在本地服務器上,而是從$令牌= FALSE測試服務器。我可以從控制檯檢索捲曲的標記。
curl -X POST "https://domain/index.php/rest/V1/integration/admin/token/" -H "Content-Type:application/json" -d '{"username":"user", "password":"password"}'
爲什麼我在PHP腳本中收到false?有任何想法嗎? curl_error($ CH)的
你可以試試'curl_errno($ CH)'和'curl_error($ CH)'調查,如果'$令牌===感謝FALSE' –
@LorenzoS,沒有什麼幫助。 –