简体   繁体   English

laravel卷曲无法在天蓝色上工作

[英]laravel curl not working on azure

I am connecting my two apps (laravel with python) using curl command. 我正在使用curl命令连接两个应用程序(laravel和python)。 It is working absolutely fine on my local server without changing a single line but when it gives me following error when on azure server 它在我的本地服务器上运行完全正常,无需更改任何一行,但是在azure服务器上出现以下错误时

POST https://myweb.com/searchJobs 500 () POST https://myweb.com/searchJobs 500()

my code is 我的代码是

$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);

is there any security protocol that I need to update on azure or what can be possible issue? 我需要在天蓝色上更新任何安全协议,或者可能出现什么问题?

Actually these lines were working fine on localhost but not on azure 实际上,这些行在localhost上运行正常,但在azure上却没有

$arr = "";
$arr['hello'] = '7';

so I changed them as 所以我把它们改成

$arr = [];
$arr['hello'] = '7';

Though i don't no why azure didn't run it. 虽然我不知道为什么天蓝色没有运行它。 If php convert it to an array on localhost than it must run on azure as well 如果php将其转换为本地主机上的数组,那么它也必须在azure上运行

Since you are using the default domain provided by azure appservice. 由于您使用的是azure appservice提供的默认域。 Instead of just using the HTTP protocol try to use the HTTPS since this is already free on the default domain provided. 尝试使用HTTPS而不是仅使用HTTP协议,因为它在提供的默认域上已经免费。 in this case try this changes. 在这种情况下,请尝试进行此更改。

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM