How to get token with PHP code for P-Series API interface

  • Scenarios

To verify how to get token for Yeastar P-Series PBX API interface, users is possible to do it by the known tool named postman software which provides web UI interface.

For programmers they have to achieve it by code level, here we share demo code for getting token with PHP language, please kindly note you have to replace variables $token_url and $login_data accordingly.


$token_url = 'https://YourCloudDomain/openapi/v1.0/get_token';
$user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64)';
$login_data = '{
"username": "CheckItInYourPBX",
"password": "CheckItInYourPBX"

$curl = curl_init($token_url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_USERAGENT, $user_agent);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $login_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);

$json_response = curl_exec($curl);



  • Results

If everything is prepared well and php code is running properly, you should get succcessful API response like attached result.

Have more questions? Submit a request


Please sign in to leave a comment.