0

i'm trying to read the call history from our pbx via rest-api. So far i get a valid json response, but in php some values are empty.

on linux commandline, i will get this value for phone numbers, eg:

curl -u user:pass -D - https://url/rest/user/10/wallboard/60
--> Result: "from":"<sip:+1234567890@domain.com>"

This is a part of my php script:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'https://url/rest/user/10/wallboard/60');
curl_setopt($ch, CURLOPT_USERPWD, $loginName . ":" . $loginPass);
$response  = curl_exec($ch);
curl_close($ch);
print ($response);
--> Result: "from":""

I guess the problem is the "<" character in the from value. Any ideas how to resolve this and get the full phone number?

Thanks a lot!

  • 1
    Are you running the PHP script through a browser? Then try encode the result: `print_r(htmlentities($response));` so the browser will show the `<` and `>` characters instead of rending them as HTML. – M. Eriksson Jan 17 '20 at 21:57
  • ok, got it! thanks a lot, that was quite easy! – Rick_Stinson Jan 17 '20 at 22:17

0 Answers0