Try to usin curl and curl php to connect to UCM62XX to call registers


#1

Hello,
First of all thank you for taking the time to read this problem.
I am trying to connect to a UCM 6200 series:
http://www.grandstream.com/support/resources/?title=UCM6200%20series
With the manual for API integration:


This connection is to download the call history, so I’m using the url:
https: // [UCM IP]: [Port] / cdrapi? [option1] = [value] & [option2] = [value] & …
If this url is executed in the browser:
https: // [UCM IP]:[Port]/cdrapi?format=json
A json returns with the calls, however if I execute it from curl in console:
curl -k -u [user]: [password] https://[UCM IP]:[PORT]/cdrapi?format=json
It returns an error 400 - Bad request
If I run it using php curl I get the same answer error 400 - bad request:

This is the code I use to connect via PHP

$ ch = curl_init ();
    curl_setopt_array ($ ch, array (
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_URL => $ url,
        CURLOPT_SSL_VERIFYPEER => 0,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_FOLLOWLOCATION => 1,
        CURLOPT_USERPWD => $ this-> user. ":" $ this-> password,
        CURLOPT_COOKIEJAR => 'cookie.txt',
        CURLOPT_COOKIEFILE => "cookie.txt",
        CURLOPT_USERAGENT => "Mozilla / 5.0 (Windows NT 10.0; Win64; x64; rv: 58.0) Gecko / 20100101 Firefox / 58.0",
        CURLOPT_TIMEOUT => 50
    ));
$ response = curl_exec ($ ch);

I have verified that I have connectivity from where I execute these commands and that the calls arrive, if I make a wget request, it downloads a file with the json, but it is a bad solution for me, since I need to manage it from a web application script .
Could it be that he is sending something wrong in the call via curl? Could it be that I need to activate something in the UCM to allow this type of connectivity?
Trying different things tb I have tried file_get_contents () from PHP and I get the same result Error 400 - Bad Request, I would like to insist that I know that the url is correct since running it in the browser works perfectly.
Note: all private data I have replaced by [FIELD] for the forum, in my production environment has real data and that work