CURL无法在php中发送GET请求

CURL无法在php中发送GET请求,php,curl,Php,Curl,我使用CURL向服务器发送get请求,但它没有生成所需的输出。 在浏览器中加载时,脚本工作正常。 它是将给定的PNG图像组合到GIF的脚本 <?php //generate GIF $name = $_GET['name_of_final_gif']; $images = $_GET['images']; $images = json_decode($images, true); //include GIF maker class based on GD library include('

我使用CURL向服务器发送get请求,但它没有生成所需的输出。 在浏览器中加载时,脚本工作正常。 它是将给定的PNG图像组合到GIF的脚本

<?php
//generate GIF
$name = $_GET['name_of_final_gif'];
$images = $_GET['images'];
$images = json_decode($images, true);
//include GIF maker class based on GD library
include('GIFEncoder.class.php');

/******************************************************/

foreach($images as $image_link) {

    // Open the source image and add the text.
    $image = imagecreatefrompng($image_link);

    // Generate GIF from the $image
    // We want to put the binary GIF data into an array to be used later,
    //  so we use the output buffer.
    ob_start();
    imagegif($image);
    $frames[]=ob_get_contents();
    $framed[]=300; // Delay in the animation.
    ob_end_clean();

}


// Generate the animated gif and save it
$gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');
$fp = fopen("gifs/$name", 'w');
fwrite($fp, $gif->GetAnimation());
fclose($fp);
?>
试试这个

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://example.com/make_gif.php?images=$images&&name_of_final_gif=$name");
curl_exec($ch); 
curl_close($ch);  
试试这个:

function curl($url) {
        // Assigning cURL options to an array
        $options = Array(
            CURLOPT_RETURNTRANSFER => TRUE,  // Setting cURL's option to return the webpage data
            CURLOPT_FOLLOWLOCATION => TRUE,  // Setting cURL to follow 'location' HTTP headers
            CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers
            CURLOPT_TIMEOUT => 120,  // Setting the maximum amount of time for cURL to execute queries
            CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow
            CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8",  // Setting the useragent
            CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function

        );

        $ch = curl_init();  // Initialising cURL



        curl_setopt_array($ch, $options);   // Setting cURL's options using the previously assigned array data in $options

        $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable

        curl_close($ch);    // Closing cURL

        return $data;   // Returning the data from the function 
    }

    $page = curl($link); 

我在代码中没有看到CURL的用法……CURL在哪里?你得到了什么输出?这里没有足够的信息。您的CURL调用在哪里?我已经在上面添加了我的CURL代码,请注意,在$\u GET方法中传递JSON对象不是一个好的实践,即使它正在工作。还请共享运行这些脚本的输出或结果。您需要添加解释。不鼓励只使用代码的答案。
function curl($url) {
        // Assigning cURL options to an array
        $options = Array(
            CURLOPT_RETURNTRANSFER => TRUE,  // Setting cURL's option to return the webpage data
            CURLOPT_FOLLOWLOCATION => TRUE,  // Setting cURL to follow 'location' HTTP headers
            CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers
            CURLOPT_TIMEOUT => 120,  // Setting the maximum amount of time for cURL to execute queries
            CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow
            CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8",  // Setting the useragent
            CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function

        );

        $ch = curl_init();  // Initialising cURL



        curl_setopt_array($ch, $options);   // Setting cURL's options using the previously assigned array data in $options

        $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable

        curl_close($ch);    // Closing cURL

        return $data;   // Returning the data from the function 
    }

    $page = curl($link);