-
Notifications
You must be signed in to change notification settings - Fork 751
RING Central SMS Integration #12504
base: developer
Are you sure you want to change the base?
RING Central SMS Integration #12504
Conversation
$cliend_secret = $this->getAuthorization(); | ||
$patch = $this->getPatch(); | ||
// | ||
$login = new RingCentral\SDK\SDK($patch['CLIENT_ID'], $cliend_secret, $url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What class is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't merge your commits because an additional library in the system is required, which in most cases won't be used. If you rewrite the communication code to "Guzzle, PHP HTTP client" (here is an example https://github.com/YetiForceCompany/YetiForceCRM/search?q=GuzzleHttp) we will merge your commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't be doing it, as it works just fine in the environment. What is the problem with Ringcentral SDK? It is an official well-maintained library. https://github.com/ringcentral/ringcentral-php
you can close the request if you don't see potential in this.
P.S
Letting you know that Ringcentral one of the largest VoIP providers in North America, so potentially including this integration will bring you more clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure about guzzle but I do have sms, call logs, and call recordings working in production. Full pbx and mms integration is feasible and I would be willing to create a pull request for complete RingCentral / Telus Business Connect support; though I am not sure what your thoughts are on using curl as its not used in the code base, please let me know.
// Call Log Auth Example
<?php
$clientId = '';
$clientSecret = '';
$jwt = '';
$url = 'https://platform.ringcentral.com/restapi/oauth/token';
$authorization = base64_encode($clientId . ':' . $clientSecret);
$appurl = 'https://platform.ringcentral.com/restapi/v1.0/account/~/call-log/?view=Detailed';
// Curl OAuth Token
$data = array(
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
'assertion' => $jwt
);
$headers = array(
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ' . $authorization
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
$resp = json_decode($response);
$token = $resp->access_token;
// Curl Call Logs
$curl = curl_init($appurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Accept: application/json',
'Authorization: Bearer ' . $token
]);
$response = curl_exec($curl);
curl_close($curl);
// Check If Call Log Already Exists In DB
$data = json_decode($response, true);
if (isset($data['records'])) {
foreach ($data['records'] as $record) {
// Query ID in database
$id = $record['sessionId'];
...
// Rough MMS / SMS Example
<?php
$from = '';
$to = '';
$text = '';
$attachment = 'data:text/plain;name=test.txt;base64,dGVzdAo=';
$appurl = 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/mms';
// OAuth Token
...
// Send SMS / MMS
$data = array(
'from' => array(
'phoneNumber' => $from
),
'text' => $text,
'attachments' => array(
$attachment
),
'to' => array(
array(
'phoneNumber' => $to
)
)
);
$curl = curl_init($appurl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Accept: application/json',
'Content-Type: multipart/mixed',
'Authorization: Bearer ' . $token
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guzzle would be better, it includes default proxy configuration and is simple to use, see
YetiForceCRM/app/RecordCollectors/UaYouControl.php
Lines 134 to 147 in f1904a6
$response = []; | |
try { | |
$response = \App\RequestHttp::getClient([ | |
'headers' => [ | |
'Authorization' => 'Bearer ' . $this->apiKey | |
] | |
])->get($this->url . $companyNumber); | |
if (200 === $response->getStatusCode()) { | |
$this->data = $this->parseData(\App\Json::decode($response->getBody()->getContents())); | |
} | |
} catch (\GuzzleHttp\Exception\GuzzleException $e) { | |
\App\Log::warning($e->getMessage(), 'RecordCollectors'); | |
$this->response['error'] = $e->getResponse()->getReasonPhrase(); | |
} |
Switch
Black Duck Security ReportBranch developer has no Black Duck results, and could not be compared to #12504. Analyze branch developer to get a change comparison. Added ComponentsMedium Risk: 3 Removed ComponentsClean: 113 |
Description
Ringcentral SMS Integration
Testing
Reuired lib: https://github.com/ringcentral/ringcentral-php
Replace send() function;
https://developers.ringcentral.com/ - create an app there;
Changes
Final checklist