Ejemplo n.º 1
0
 /**
  * @deprecated This is a depreciated method and will be removed in version 7.3.
  */
 public function getLatestUpdates($maxTime, $maxEntries)
 {
     $td = $GLOBALS['timedate'];
     try {
         if (!$this->setupFacebookLib()) {
             // FIXME: Translate
             return array('success' => FALSE, 'errorMessage' => 'Facebook does not have the required libraries.');
         }
         $fbMessages = $this->fb->api('/me/home?limit=' . $maxEntries);
     } catch (FacebookApiException $e) {
         // We should ask user about second login to facebook because our access_token is dead.
         if ($e->getType() == 'OAuthException' && !empty($this->eapmBean->id)) {
             return array('success' => true, 'messages' => array(array('ID' => create_guid(), 'sort_key' => time(), 'NAME' => translate('LBL_ERR_OAUTH_FACEBOOK_1', 'EAPM') . ' <a href="#" onclick="window.open(\'index.php?module=EAPM&amp;refreshParentWindow=1&amp;closeWhenDone=1&amp;action=QuickSave&amp;application=Facebook\',\'EAPM\');">' . translate('LBL_ERR_OAUTH_FACEBOOK_2', 'EAPM') . '</a>.')));
         }
         $GLOBALS['log']->error('Facebook Error: ' . $e->getMessage());
         return array('success' => FALSE, 'errorMessage' => translate('LBL_ERR_FACEBOOK', 'EAPM'));
     }
     if (!isset($fbMessages['data'][0])) {
         return array('success' => TRUE, 'messages' => array());
     }
     $messages = array();
     foreach ($fbMessages['data'] as $message) {
         if (empty($message['message'])) {
             continue;
         }
         $unix_time = strtotime($message['created_time']);
         $fake_record = array();
         $fake_record['sort_key'] = $unix_time;
         $fake_record['ID'] = create_guid();
         $fake_record['DATE_ENTERED'] = $td->to_display_date_time(gmdate('Y-m-d H:i:s', $unix_time));
         $fake_record['NAME'] = $message['from']['name'] . '</b>';
         if (!empty($message['message'])) {
             $fake_record['NAME'] .= ' ' . $message['message'];
         }
         if (!empty($message['picture'])) {
             $fake_record['NAME'] .= '<br><!--not_in_theme!--><img src="' . $message['picture'] . '" height=50>';
         }
         $fake_record['NAME'] .= '<br><div class="byLineBox"><span class="byLineLeft">' . SugarFeed::getTimeLapse($fake_record['DATE_ENTERED']) . '&nbsp;</span><div class="byLineRight">&nbsp;</div></div>';
         $fake_record['IMAGE_URL'] = "https://graph.facebook.com/" . $message['from']['id'] . '/picture';
         $messages[] = $fake_record;
     }
     return array('success' => TRUE, 'messages' => $messages);
 }
Ejemplo n.º 2
0
 public function testgetTimeLapse()
 {
     $result = SugarFeed::getTimeLapse('2016-01-15 11:16:02');
     $this->assertTrue(isset($result));
     $this->assertGreaterThan(0, strlen($result));
 }