简体   繁体   English

PHP curl获取多维数组

[英]PHP curl get multidimensional array

I'm trying to get a list of issues using gitlab API. 我正在尝试使用gitlab API获取问题列表。 The response is correct testing the URL, but the curl doesnot execute in my php code. 响应正确地测试了URL,但是curl没有在我的php代码中执行。 I guess it`s because of the multidimensional array. 我猜是因为多维数组。 but how do you solve this? 但是你怎么解决呢? Here is my function: 这是我的功能:

function getissues_list () {

    $url = MAIN_URL."/issues";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPGET , true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this->token);
    $response = curl_exec($ch);

    if (!curl_exec($ch)) {

        echo ($this->exception_message);

    } else{
        return $response;
        curl_close($ch);
    }

}

Thanks! 谢谢!

function getissues_list () {
    global MAIN_URL; // Is this accessible in this function?

    $url = MAIN_URL."/issues";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPGET , true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this->token);
    $response = curl_exec($ch);

    var_dump($response);// ADD THIS LINE TO DEBUG!!!!!!!!

    if (!curl_exec($ch)) {
        echo ($this->exception_message);
    } else{
        return $response;
        curl_close($ch);
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM