国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - laravel uses curl request, the return value is considered to be a request and an error occurs
過(guò)去多啦不再A夢(mèng)
過(guò)去多啦不再A夢(mèng) 2017-06-05 11:08:44
0
1
1177

Requirement background:
The project needs to make a curl request to other platforms. I send my mobile phone number, and the other platforms send verification codes to the users and send me a successful receipt.
Question:
Local Debugging is no problem, but when going to the server, the $data data in the curl receipt, that is, $data = curl_exec($curl);, is regarded as a request, and the token of this $data must be verified. Look for his distribution rules in the routing file...
My troubleshooting ideas:
I first added such a sentence var_dump(Request: :path()):

public function handle($request, Closure $next)

{

var_dump(Request::path());
if ($this->isReading($request) || $this->shouldPassThrough($request) || $this->tokensMatch($request)) {
    return $this->addCookieToResponse($request, $next($request));
}

throw new TokenMismatchException;

}

The path printed out is the URL for sending the curl request, and then there is the platform URL for curl communication, which led to the reason why I reported csrf_token errors and path errors later.

The control of when I send curl requests The device method is:

/*
 * 發(fā)送驗(yàn)證碼請(qǐng)求
 */

public function ajaxRquest(Request $request) {
    $input['tel_num'] = $request->input('tel');
    $url = config('Api');
    $url = $url['sendVerifyCode'];
    if ($request->input('code_attr') == 'submitInformation') {
        $input['union_event'] = 'submitInformation';
    } else {
        $input['union_event'] = 'queryProgress';
    }
    $result = $this->postCurlInfo($url, json_encode($input));
    return $result;
}

public function postCurlInfo($url, $data) {
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $data,
        CURLOPT_HTTPHEADER => array(
            "cache-control: no-cache",
            "content-type: application/json",
        ),
    ));
    return curl_exec($curl);
}

And the path I printed out is:

string(16) "Index/ajaxRquest" string(31) "v1/serviceCenter/sendVerifyCode"

The first string is the method path I used to send curl, and the latter one is the url to send the receipt.

I think it is very strange. The return of curl should not be regarded as a request! May I ask why this happens? Thank you!

過(guò)去多啦不再A夢(mèng)
過(guò)去多啦不再A夢(mèng)

reply all(1)
過(guò)去多啦不再A夢(mèng)

I don’t understand your question, but to initiate an http request, direct curl operation is not recommended. You can try the zttp library recommended by laravel

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template