[英]laravel curl not working on azure
我正在使用curl命令連接兩個應用程序(laravel和python)。 它在我的本地服務器上運行完全正常,無需更改任何一行,但是在azure服務器上出現以下錯誤時
POST https://myweb.com/searchJobs 500()
我的代碼是
$ch = curl_init();
//URL to send the request to
curl_setopt($ch, CURLOPT_URL, 'http://python-scrapper-python001.azurewebsites.net/myfunction');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
//We are doing a post request
curl_setopt($ch, CURLOPT_POST, 1);
//adding the post data to request
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
//Return instead of outputting directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
我需要在天藍色上更新任何安全協議,或者可能出現什么問題?
實際上,這些行在localhost上運行正常,但在azure上卻沒有
$arr = "";
$arr['hello'] = '7';
所以我把它們改成
$arr = [];
$arr['hello'] = '7';
雖然我不知道為什么天藍色沒有運行它。 如果php將其轉換為本地主機上的數組,那么它也必須在azure上運行
由於您使用的是azure appservice提供的默認域。 嘗試使用HTTPS而不是僅使用HTTP協議,因為它在提供的默認域上已經免費。 在這種情況下,請嘗試進行此更改。
$ch = curl_init();
//URL to send the request to
curl_setopt($ch, CURLOPT_URL, 'https://python-scrapper-python001.azurewebsites.net/myfunction');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
//We are doing a post request
curl_setopt($ch, CURLOPT_POST, 1);
//adding the post data to request
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
//Return instead of outputting directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.