Пример #1
0
 /**
  * Test setter/getter method for session.
  * @covers \BogCon\YahooMessengerApi\Client::setSession
  * @covers \BogCon\YahooMessengerApi\Client::getSession
  * @covers \BogCon\YahooMessengerApi\Client::hasSession
  */
 public function testSetGetHasSession()
 {
     $arrSession = array('sessionId' => 'someTestSessionId', 'primaryLoginId' => 'someLoginId', 'displayInfo' => array('avatarPreference' => 0), 'server' => 'rcore3.messenger.yahooapis.com', 'notifyServer' => 'rproxy3.messenger.yahooapis.com', 'constants' => array('presenceSubscriptionsMaxPerRequest' => 500));
     $objYM = new Client('das1sdas', 'dasda123sdas', 'appKey', 'appSecret');
     $this->assertSame(array(), $objYM->getSession());
     $objYM->setSession($arrSession);
     $this->assertSame($arrSession, $objYM->getSession());
     $this->assertTrue($objYM->hasSession());
     $objYM->setSession(array());
     $this->assertFalse($objYM->hasSession());
 }
Пример #2
0
                 $arrReturnValue['response'] = 'Could not get user avatar.';
                 Logger::log($objEx->getMessage());
             }
         }
     }
     break;
     /* GET NOTIFICATIONS */
 /* GET NOTIFICATIONS */
 case 'get_notifications':
     if (!checkLocalLogin()) {
         $arrReturnValue['response'] = 'You must be logged in order to retrieve notifications.';
     } else {
         try {
             $objYM = new Client($_SESSION['username'], $_SESSION['pwd'], APP_CONSUMER_KEY, APP_CONSUMER_SECRET);
             $objYM->setTokens($_SESSION['ym_tokens']);
             $objYM->setSession($_SESSION['ym_session']);
             $notifications = $objYM->fetchNotifications($_SESSION['ym_notifications_seq']);
             Logger::log(var_export($notifications, 1));
             $arrAjaxResponse = array();
             foreach ($notifications['responses'] as $notificationsResponse) {
                 foreach ($notificationsResponse as $notificationType => $notif) {
                     switch ($notificationType) {
                         case 'logOff':
                             $arrAjaxResponse[] = array('type' => $notificationType, 'info' => array('buddy' => htmlspecialchars($notif['buddy'])));
                             break;
                         case 'buddyInfo':
                             foreach ($notif['contact'] as $notifContact) {
                                 $info = array('buddy' => htmlspecialchars($notifContact['sender']), 'network' => isset($notifContact['network']) ? $notifContact['network'] : 'yahoo', 'presenceMessage' => '', 'presenceState' => '');
                                 if (isset($notifContact['customDNDStatus'])) {
                                     if (0 == $notifContact['customDNDStatus'] && 99 == $notifContact['presenceState']) {
                                         $notifContact['presenceState'] = Client::USER_IS_ONLINE;