Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

RING Central SMS Integration #12504

Open
wants to merge 3 commits into
base: developer
Choose a base branch
from
Open

RING Central SMS Integration #12504

wants to merge 3 commits into from

Conversation

z0lo13
Copy link

@z0lo13 z0lo13 commented Feb 1, 2020

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

  • Bug fix (non-breaking change which fixes an issue)
  • [ X] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

$cliend_secret = $this->getAuthorization();
$patch = $this->getPatch();
//
$login = new RingCentral\SDK\SDK($patch['CLIENT_ID'], $cliend_secret, $url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What class is this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Author

@z0lo13 z0lo13 May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariuszkrzaczkowski

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariuszkrzaczkowski

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);

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

$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();
}

@blackduck-copilot
Copy link

blackduck-copilot bot commented Apr 22, 2021

Black Duck Security Report

Branch developer has no Black Duck results, and could not be compared to #12504. Analyze branch developer to get a change comparison.

Added Components

Medium Risk: 3
Clean: 690

Removed Components

Clean: 113

Click here to see full report

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⏸ Not Finished This pull request is not finished. 👮‍♂️ VerificationRequired We have to verify if this issue exists in the developer version of YetiForce.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants