Git Product home page Git Product logo

Comments (12)

kirill-konshin avatar kirill-konshin commented on June 27, 2024

You have to add

use RC\subscription\Subscription;

statement or refer to the full name of class: RC\subscription\Subscription.

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024

Should it not be included in the autoloader?

from ringcentral-php.

kirill-konshin avatar kirill-konshin commented on June 27, 2024

Autoloader only tells php where to locate files, so it's already covered by Autoloader.

In the rest of your code you use full class names and it works, so do the same for subscription. Or have one use statement at the top of your file.

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024

Okay thank you very much. I was confused about autoloading but you cleared it up.

from ringcentral-php.

kirill-konshin avatar kirill-konshin commented on June 27, 2024

No problem :)

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024

Receiving this error. I don't want to change protected to public without your advice.

Stack Trace

PHP Fatal error:  Call to protected method RC\subscription\Subscription::notify() from context 'Pubnub\Pubnub' in /home/rafael/PhpstormProjects/ringcentral-vm/vendor/pubnub/pubnub/composer/lib/Pubnub/Pubnub.php on line 468
PHP Stack trace:
PHP   1. {main}() /home/rafael/PhpstormProjects/ringcentral-vm/program.php:0
PHP   2. VMDownloader->startListener() /home/rafael/PhpstormProjects/ringcentral-vm/program.php:62
PHP   3. RC\subscription\Subscription->register($options = *uninitialized*) /home/rafael/PhpstormProjects/ringcentral-vm/program.php:44
PHP   4. RC\subscription\Subscription->subscribe($options = *uninitialized*) /home/rafael/PhpstormProjects/ringcentral-vm/vendor/ringcentral/php-sdk/lib/RC/subscription/Subscription.php:76
PHP   5. RC\subscription\Subscription->subscribeAtPubnub() /home/rafael/PhpstormProjects/ringcentral-vm/vendor/ringcentral/php-sdk/lib/RC/subscription/Subscription.php:119
PHP   6. Pubnub\Pubnub->subscribe($channel = *uninitialized*, $callback = *uninitialized*, $timeToken = *uninitialized*, $presence = *uninitialized*) /home/rafael/PhpstormProjects/ringcentral-vm/vendor/ringcentral/php-sdk/lib/RC/subscription/Subscription.php:241
PHP   7. Pubnub\Pubnub->_subscribe($channel = *uninitialized*, $channelGroup = *uninitialized*, $callback = *uninitialized*, $timeToken = *uninitialized*, $presence = *uninitialized*) /home/rafael/PhpstormProjects/ringcentral-vm/vendor/pubnub/pubnub/composer/lib/Pubnub/Pubnub.php:365

Program.php

<?php

require_once('vendor/autoload.php');

use \RC\SDK;
use \RC\subscription\events\NotificationEvent;
use \RC\subscription\Subscription;

class VMDownloader
{
    // Configuration
    const KEY         = 'my_app_key';
    const SECRET      = 'my_app_secret';
    const SERVER      = 'https://platform.devtest.ringcentral.com';
    const MAIN_NUMBER = 'my_username';
    const PASSWORD    = 'my_password';

    private $sdk;

    function __construct()
    {
        $this->sdk = new SDK(self::KEY, self::SECRET, self::SERVER);
        $this->sdk->getPlatform()->authorize(self::MAIN_NUMBER, '', self::PASSWORD, true);
    }

    public function getVoicemails()
    {
        return $this->sdk->getPlatform()
            ->get('/account/~/extension/~/message-store', ['messageType' => 'VoiceMail'])
            ->getJson();
    }

    /**
     * Listens for new messages
     */
    public function startListener()
    {
        $this->sdk->getSubscription()
            ->addEvents(['/restapi/v1.0/account/~/extension/~/message-store'])
            ->on(Subscription::EVENT_NOTIFICATION, function (NotificationEvent $e) {

                print_r($e->getPayload());

                // TODO: Add curl downloader

            })
            ->register();
    }

    /**
     * @todo finish function definition
     */
    private function download()
    {
    }

    function __destructor()
    {
        print 'Destroyed';
    }
}

$t = new VMDownloader();

$t->startListener();

from ringcentral-php.

kirill-konshin avatar kirill-konshin commented on June 27, 2024

What version of PHP do you have?

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024
rafael@rcepeda:~/Downloads/PhpStorm-141.1912/bin$ php -v
PHP 5.6.4-4ubuntu6.2 (cli) (built: Jul  2 2015 15:29:28) 

from ringcentral-php.

kirill-konshin avatar kirill-konshin commented on June 27, 2024

I've pushed a small fix for your case, go ahead and try. The fix is in DEVELOP branch.

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024

Thank you sir.
On Jul 17, 2015 3:28 PM, "Kirill Konshin" [email protected] wrote:

I've pushed a small fix for your case, go ahead and try. The fix is in
DEVELOP branch.


Reply to this email directly or view it on GitHub
#2 (comment).

from ringcentral-php.

grokify avatar grokify commented on June 27, 2024

@ralph3991: I replaced the app and user credentials with placeholders in your posts. For security purposes, please don't post your app and user credentials online.

from ringcentral-php.

MrOutput avatar MrOutput commented on June 27, 2024

okay, since it was a sandbox, I did not mind it. But I gotcha

from ringcentral-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.