对象转移到了这里。 PHP CURL

时间:2019-06-26 02:42:42

标签: php-curl

我尝试使用curl在该网站https://employer.bestjobs.ph/中登录 我拥有所有凭据,但总是说“对象已移至此处”。这是我的下面的代码

define('USER_AGENT', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36');
    define('COOKIE_FILE', 'D:\wamp\www\sbsearch\cookies.txt');
    define('LOGIN_FORM_URL', 'https://employer.bestjobs.ph/Login');
    define('LOGIN_ACTION_URL', 'https://employer.bestjobs.ph/Login');

    $postValues =array("_requestverificationtoken"=>"Hc7MCSi5q43cczcGF0DdsXDQBh-1Yr957gB1eekTdAemUKmeyZmh130IgvaHTBJDVGReBVkoo2Id-3sJckN2Xk4p8_U1","keepmeloggedin"=>"false","password"=>"mypassword","username"=>"myusername");

    $curl = curl_init();

    curl_setopt($curl, CURLOPT_URL, LOGIN_ACTION_URL);                                                                                                                                    
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postValues));
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);

    curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
    curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);   
    curl_setopt($curl, CURLOPT_REFERER, LOGIN_FORM_URL);

    if(curl_errno($curl)){
       throw new Exception(curl_error($curl));
    }

    //protected page
    curl_setopt($curl, CURLOPT_URL, 'https://employer.bestjobs.ph/Company');

    curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
    curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);

    // curl_setopt($curl, CURLE_LOGIN_DENIED , 3);
    $output =  curl_exec($curl);
    curl_close($curl);
    echo $output;

0 个答案:

没有答案