Problems with curl - response

Discussion in 'General' started by Yel4144, Apr 6, 2024.

  1. Yel4144

    Yel4144 New Member

    This problem might not be a problem with ISPConfig, but I'm desperatly looking for some advices:
    I migrated ISPConfig 3.2.11p2 on Ubuntu 20.04 LTS with PHP7.4 as default
    ISPConfig 3.2.11p2 on Ubuntu 22.04 LTS with PHP8.1

    I have a script that fetches mailadresses from an external provider and adjustes ISPC forwarding groups. This just won't work anymore on the new server.

    My call
    Code:
    $memberIds = getData($domain . "/api/1/member?filter=" . $filter[$i] . "&order=`E-Mail` ASC&apikey=" . $apiKey)["objects"];
    calls
    Code:
    function getData($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL,$url);
        $result=curl_exec($ch);
        curl_close($ch);
        return json_decode($result, true);
    }
    which returns nothing (just empty, no array or anything) on the new server, but does return on the old one.

    The URL itself returns
    Code:
    {"objects":[3243,20264,3084,19037,104,118,13574,13990,91,17029,497,7401,14576,13421,1323,12782,124,17417,99,16834,19038,5230,12787,13946,12781,119,92,20233,125,120,117]}
    
    on the old server getData returns
    3243,20264,3084,19037,104,118,13574,13990,91,17029,497,7401,14576,13421,1323,12782,124,17417,99,16834,19038,5230,12787,13946,12781,119,92,20233,125,120,117
    on the new one the array is just empty
    I have no idea what it could be: Any help very welcome!!!
    I already tried switching PHP from 8.1 to 7.4 with same result.

    One thing: Fetching the forwarding adresses in ISPC had also a problem:
    I had to adjust
    Code:
    $mail_forward_record = $client->mail_forward_get($session_id, array('source' => '[email protected]'));
    $mail_forward_record[0][destination]
    to
    Code:
    $mail_forward_record[0]['destination']
    --> does this help?
     
  2. Yel4144

    Yel4144 New Member

    Found it out by adding this to getData
    PHP:
    if(curl_errno($ch)){
            echo 
    'URL: ' $url '<br>';
            echo 
    'Curl error: ' curl_errno($ch) .' 'curl_error($ch) .'<br>';
    }
    --> this returned 3 and pointed to the URL containing a space!!!
    Code:
    order=`E-Mail` ASC&apikey
     

Share This Page