Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用第一个请求中的数据在curl请求之后发送curl请求?_Php_Curl_Request - Fatal编程技术网

Php 如何使用第一个请求中的数据在curl请求之后发送curl请求?

Php 如何使用第一个请求中的数据在curl请求之后发送curl请求?,php,curl,request,Php,Curl,Request,我想寄两张卷发单。 第一: 我想寄两张卷发单。发送第一个请求后,我需要从第一个请求中获取$found\uURL,并发送第二个请求。如何正确实施这一点?我知道这可能是一个愚蠢的问题,但我还是坚持了下来。修改第一个auth以始终返回某些内容,方法是向“未找到的部分”添加一个返回,以返回null或空,或者将返回移到if语句之外。那么下面的代码应该可以工作了 $foundUrl = auth($url); if($foundUrl){ $html = auth1($foundUrl); } 代码

我想寄两张卷发单。 第一:


我想寄两张卷发单。发送第一个请求后,我需要从第一个请求中获取$found\uURL,并发送第二个请求。如何正确实施这一点?我知道这可能是一个愚蠢的问题,但我还是坚持了下来。

修改第一个auth以始终返回某些内容,方法是向“未找到的部分”添加一个返回,以返回null或空,或者将返回移到if语句之外。那么下面的代码应该可以工作了

$foundUrl = auth($url);
if($foundUrl){
   $html = auth1($foundUrl);
}

代码看起来没问题,只需将第一个方法的返回移出else语句。
function auth1($found_url) {
    $ch = curl_init($found_url);
    curl_setopt($ch, CURLOPT_URL, $found_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0");
    curl_setopt($ch, CURLOPT_COOKIEFILE, $user_cookie_file);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $user_cookie_file);
    curl_setopt($ch, CURLOPT_POST, 0);

    $headers = array(
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
        'Accept-Encoding: gzip, deflate, br',
        'Content-Type: application/x-www-form-urlencoded',
        'Connection: keep-alive',
        'Upgrade-Insecure-Requests: 1',

    );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $html = curl_exec($ch);
    echo $html;
    return $html;

}
$foundUrl = auth($url);
if($foundUrl){
   $html = auth1($foundUrl);
}