cURL with basic authorization

    public static function curl($url){
        $username = self::$username;
        $password = self::$pw;

        $header = array();
        $header[] = "Authorization: Basic ".base64_encode($username.":".$password);
        $header[] = "Content-Type: application/json";
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        $errors = curl_error($ch);
        //logg($errors);

        $data = curl_exec($ch);
        //logg($data);
        //$info = curl_getinfo($ch);
        curl_close ($ch);

        if($data == false){
            return false;
        }else{
            $data = json_decode($data);
            return $data;
        }
    }