News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
How to Use PHP on Cpanel to get Call Logs From All Users
Tags: call logs, rest api
Dec 18, 2020 at 7:52am   •   1 replies  •  0 likes
DANG designs

I've been researching on how to access the logs for RingCentral for a while now and I'm having a bit of trouble. Essentially, I want to use a file on our web server to call the API and fetch all the records for every user (not just the owner account that I have the credentials set up on). Afterwards, I plan to store them in our database but I don't think I'll have issues there. From the link below, and other alternatives I've tried (Zapier), it appears that I need the username, password, and extension to get all this information collectively. Is there a way to get this information without requiring all users' passwords?

https://developers.ringcentral.com/guide/voice/call-log/reading-call-log#php

1 Answer
answered on Dec 18, 2020 at 10:05am  

You need to login your app with an admin user and use the account call log API:

https://developers.ringcentral.com/api-reference/Call-Log/readCompanyCallLog


 0
on Dec 18, 2020 at 12:46pm   •  0 likes

Thank you for reaching out!

I think that page leads me to have more questions. What is the accountid and where can I find it in the ringCentral account? What is the serverURL for the getenv variable? Also, the 27th line shows login information where the password is still required, right?

on Dec 18, 2020 at 1:52pm   •  1 likes
on Dec 30, 2020 at 11:35am   •  0 likes

Thanks for the heads up. I'm still having a bit of trouble. I can get the authorization code now but I can't seem to get the token. Here is the code that I'm using:

curl_setopt_array($curlpost, array(
    CURLOPT_URL => "https://platform.devtest.ringcentral.com/restapi/oauth/token?code={$authCode}&grant_type={$grant_type}&redirect_uri={$redirect_uri}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => array(
        "Accept: application/json",
        "Content-Type: application/x-www-form-urlencoded",
        "Authorization: Basic " .$base64test
    ),
    ));
    



on Dec 30, 2020 at 11:36am   •  0 likes


The grant type is set to "authorization_code", auth code is set to the authorization code provided from the initial get request, and the redirect uri is correct. base64test is clientid:clientsecret (and I'm not positive that is correct). Any advice?

on Dec 30, 2020 at 11:42am   •  0 likes

This is what I get btw

{

"error" : "invalid_grant",

"errors" : [ {

"errorCode" : "OAU-222",

"message" : "Account does not exist"

} ],

"error_description" : "Account does not exist"

}

on Jan 4, 2021 at 7:58am   •  0 likes

What is your app auth flow, password flow or 3-legged authorization flow?

For authorization flow, see this quick start (using the RingCentral PHP SDK). Is there any reason you don't want to use the SDK?

In your code, you passed the code and other params incorrectly. They must be in the body params, not as query params.


CURLOPT_URL => "https://platform.devtest.ringcentral.com/restapi/oauth/token?code={$authCode}&grant_type={$grant_type}&redirect_uri={$redirect_uri}"

Check the documentation: https://developers.ringcentral.com/guide/authentication/auth-code-flow

on Dec 30, 2020 at 11:35am   •  0 likes

Thanks for the heads up. I'm still having a bit of trouble. I can get the authorization code now but I can't seem to get the token. Here is the code that I'm using:

curl_setopt_array($curlpost, array(
    CURLOPT_URL => "https://platform.devtest.ringcentral.com/restapi/oauth/token?code={$authCode}&grant_type={$grant_type}&redirect_uri={$redirect_uri}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => array(
        "Accept: application/json",
        "Content-Type: application/x-www-form-urlencoded",
        "Authorization: Basic " .$base64test
    ),
    ));
    





A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us