question

Raymond Labasano avatar image
Raymond Labasano asked Raymond Labasano commented

Webhook subscription error

Hi please check this code for me and see what's wrong and if someone can fix it. Issue is subscription error.


https://drive.google.com/drive/folders/1Zswnlp4qwMGM31numcbDKoDZRjXm-uSx?usp=sharing



<?php

function curlPost($url, $header, $data, $type){

$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_POST, true);

if($type){

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

}else{

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

}

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch);

curl_close ($ch);

$responce = json_decode($result,true);

return($responce);

}


function curlGet($url, $header){

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch);

curl_close ($ch);

$responce = json_decode($result,true);

return($responce);

}

function get_Access_token_by_refresh_token($get_refresh_token){

$url = BASE_URL."/restapi/oauth/token";

$headers = array();

$auth = base64_encode(CLIENT_ID .":". APP_SECRET);

$headers[] = "Content-Type: application/x-www-form-urlencoded";

$headers[] = "Authorization: Basic ".$auth;

$data = array(

"grant_type" => "refresh_token",

"refresh_token" => $get_refresh_token

);

$response = curlPost($url, $headers, $data, false);

return $response;

}

/*

Get Token

*/


function subscribe($token){

$url= BASE_URL."/restapi/v1.0/subscription";

$headers = array();

$headers[] = "Content-Type: application/json";

$headers[] = "Authorization: Bearer ".$token;

$headers[] = "Accept: application/json";

$data = array("eventFilters"=>array("/restapi/v1.0/account/~/presence?detailedTelephonyState=true"), "deliveryMode"=>array( "transportType"=> "WebHook","address"=>"https://tbmslive.com/ringcentral/safeforu/webhook.php"));

$response = curlPost($url, $headers, json_encode($data), true);

return $response;

}


function readPresence($token){

$url= BASE_URL."/restapi/v1.0/account/~/extension/~/presence";

$headers = array();

$headers[] = "Content-Type: application/json";

$headers[] = "Authorization: Bearer ".$token;

$headers[] = "Accept: application/json";

$response = curlGet($url, $headers);

return $response;

}


function getSubscription($token){

$url= BASE_URL."/restapi/v1.0/subscription";

$headers = array();

$headers[] = "Content-Type: application/json";

$headers[] = "Authorization: Bearer ".$token;

$headers[] = "Accept: application/json";

$response = curlGet($url, $headers);

return $response;

}

function renewSubscription($token, $id){

$url= BASE_URL."/restapi/v1.0/subscription/".$id."/renew";

$headers = array();

$headers[] = "Content-Type: application/json";

$headers[] = "Authorization: Bearer ".$token;

$headers[] = "Accept: application/json";

$data = array();

$response = curlPost($url, $headers, json_encode($data), true);

return $response;

}

webhooks
8 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

And I just reported the communication as spam as I received the email as well. Wondering if Yatin actually works for RingCentral.

2 Likes 2 ·

@Raymond Labasano
I can see you created 2 issues for the exact same question.
Requesting you to stick to only asking one question to avoid duplicate.
I am closing one of the issues for the same reason

-1 Like -1 ·
Andrew Brown avatar image Andrew Brown Yatin Gera ♦♦ ·

I am not sure why I got this notification - it has nothing to do with me????

0 Likes 0 ·

I am with Andrew Brown. Why am I receiving an email notification when I have nothing to do with this issue/post? It appears you guys have some issues with your site....

0 Likes 0 ·
chad-knighten avatar image chad-knighten Yatin Gera ♦♦ ·

Same here. Doesn't involve me at all. Hmm makes me wonder, maybe Raymond didn't actually post twice? :-)

0 Likes 0 ·
Show more comments

0 Answers

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys