-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription class not in autoloader #2
Comments
You have to add use RC\subscription\Subscription; statement or refer to the full name of class: |
Should it not be included in the autoloader? |
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. |
Okay thank you very much. I was confused about autoloading but you cleared it up. |
No problem :) |
Receiving this error. I don't want to change protected to public without your advice. Stack TracePHP 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(); |
What version of PHP do you have? |
|
I've pushed a small fix for your case, go ahead and try. The fix is in DEVELOP branch. |
Thank you sir.
|
@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. |
okay, since it was a sandbox, I did not mind it. But I gotcha |
Was this done intentionally?
The text was updated successfully, but these errors were encountered: