dougu1985 2015-10-25 21:13
浏览 11

CURL没有显示正确的东西

someone told me to use CURL to bypass cloudflare for getting text on a site so i tried it but i just cant understand how i echo out

$link1 = "http://habmoon.org/moonstream/djlook?habbie={$r->habbo}";
$link2 = "https://www.habbo.com/habbo-imaging/avatarimage?figure={$link1}";                 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $link1);
    curl_exec($ch);
    curl_close($ch);

The only thing it shows is $link1 because i dont know how to echo out the text from curl_setopt($ch, CURLOPT_URL, $link1); in $link2.

  • 写回答

1条回答 默认 最新

  • douxiangdiao6348 2015-10-25 22:19
    关注

    Hello friend you need to use CURLOPT_RETURNTRANSFER to get the request output:

    $ch = curl_init();
    
    $opts = [
        CURLOPT_URL => 'a site',
        CURLTOP_RETURNTRANSFER => TRUE
    ];
    
    curl_setopt_array($opts);
    $response = curl_exec($ch);
    
    var_dump($response);
    

    And remember, if you need to request a https use a ca file or:

    CURLOPT_SSL_VERIFYPEER => FALSE
    CURLOPT_SSL_VERIFYHOST => FALSE
    

    Good luck.

    评论

报告相同问题?