0

i was trying some thing but it doenst seem to work out that well.. it only outputs CURLE_URL_MALFORMAT & No URL set! how can i fix this?..

It needs to echo out the text on the page $link1

    <?php
        $link1 = "http://www.lubbo-zone.nl/script2/?name=iChris.";

        $ch = curl_init();

        $opts = [ 'CURLOPT_RETURNTRANSFER' => 1 ,   'CURLOPT_URL' => "{$link1}"];

        curl_setopt_array($ch , array($opts));
        $response = curl_exec($ch);

        echo curl_errno($ch) . '<br/>';
        echo curl_error($ch) . '<br/>';

        var_dump($response);
    ?>
2
  • What are you wanting to happen? "doesn't work" isn't a good description. Commented Nov 1, 2015 at 21:16
  • It needs to echo out the $link1 so i can use the code from that link for a image generator. @Teepeemm Commented Nov 1, 2015 at 21:17

2 Answers 2

2

You have a bug in your code. You are wrapping the options array in another array

$opts = [ 'CURLOPT_RETURNTRANSFER' => 1 ,   'CURLOPT_URL' => "{$link1}"];

curl_setopt_array($ch , array($opts)); // ends up being array(array(...opts))

Change the line curl_setopt_array($ch , array($opts)); to curl_setopt_array($ch , $opts);

Here is the entire code. Your CURLOPT_ constants should NOT be quoted either

<?php
$link1 = "http://www.lubbo-zone.nl/script2/?name=iChris.";

$ch = curl_init();

// your CURLOPT_ constants should NOT be quoted either
$opts = [ CURLOPT_RETURNTRANSFER => 1 , CURLOPT_URL => $link1];

curl_setopt_array($ch , $opts);
$response = curl_exec($ch);

echo curl_errno($ch) . '<br/>';
echo curl_error($ch) . '<br/>';

var_dump($response);
?>
Sign up to request clarification or add additional context in comments.

Comments

0

I used this, it gets back me response from the server, page that says checking your browser, but after some seconds redirect to some other URL.

So, I'm pretty sure you're setting options in wrong way.

$link1 = "http://www.lubbo-zone.nl/script2/?name=iChris.";

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $link1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);

    echo curl_errno($ch) . '<br/>';
    echo curl_error($ch) . '<br/>';

    var_dump ($response);

This is what I get

enter image description here

6 Comments

with this code that is in my answer? you still get URL not set?
with your code i get the same as you have but i dont know how to use curl on cloudflare and i searched many posts on stack for it but not a single answer that works
sites hosted with cloudflare having an extra layer of protection, so either you've to use selenium or use phantom JS to get pass to that page, and do have a close look how next URL is being formatted, as this is url http://www.lubbo-zone.nl/cdn-cgi/l/chk_jschl?jschl_vc=a3a1417a04ca6c59eae84a24e7912bf5&pass=1446415783.991-JWorDSaw2H&jschl_answer=-5 so when first response comes back from server, it has special header that is being used in this url that is Refresh:8;URL=/cdn-cgi/l/chk_jschl?pass=1446415783.991-JWorDSaw2H find the other ones and format url and hit that url
huh? selenium? @Mubin
yes, if you know how to use that. Good Luck mate :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.