当前位置: 首页>>代码示例>>PHP>>正文


PHP UserHelper::create方法代码示例

本文整理汇总了PHP中UserHelper::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserHelper::create方法的具体用法?PHP UserHelper::create怎么用?PHP UserHelper::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserHelper的用法示例。


在下文中一共展示了UserHelper::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllComments

 /**
  * Get all of the network comments and import them into the local database 
  *
  * @return void
  */
 public static function getAllComments($time_interval = null)
 {
     //Go through the item table in blocks of 1000
     switch (strtolower($time_interval)) {
         case 'hour':
         case 'day':
         case 'week':
         case 'month':
         case 'year':
             $time_constraint = " AND DATE_SUB(CURDATE(), INTERVAL 1 {$time_interval}) <= created";
             break;
         default:
             $time_constraint = '';
     }
     global $dbh;
     $block_size = 1000;
     $items = array();
     $sql = 'SELECT max(itemID) AS maxID FROM ' . FEED_DB . '.item';
     $last_id_query = DB::getArray($sql, __LINE__, __FILE__);
     $max_id = $last_id_query[0]['maxID'];
     $last_item = $max_id;
     echo "starting backwards count from last id {$last_item} \n";
     while ($last_item > 0) {
         $xids = array();
         $i = 0;
         while ($i < $block_size) {
             if (!$items) {
                 if ($last_item < 0) {
                     $i = $block_size;
                 } else {
                     $first_item = $last_item - $block_size;
                     $sql = 'SELECT itemID FROM ' . FEED_DB . '.item WHERE itemID > ' . $first_item . ' AND itemID <= ' . $last_item . $time_constraint;
                     $items = DB::getArray($sql, __LINE__, __FILE__);
                     $last_item = $first_item;
                     if (count($items) == 0) {
                         $i = $block_size;
                     }
                 }
             }
             while ($row = array_pop($items)) {
                 $xids[] = $row['itemID'];
                 if (++$i >= $block_size) {
                     break;
                 }
             }
         }
         if (!$xids) {
             echo 'Empty result; we are done!' . "\n";
             break;
         }
         echo 'sending block of ' . count($xids) . ' feed ids to facebook' . "\n";
         echo 'feed item ids: ' . $xids[0] . '-' . end($xids) . "\n";
         $xid_sql = implode(',', DB::s($xids));
         // pull comments for xids
         try {
             $fql = "select xid , post_id, fromid, time , text , id , username , reply_xid from comment where xid in ({$xid_sql})";
             $results = self::getClient()->api_client->fql_query($fql);
         } catch (Exception $e) {
             $results = array('error_code' => $e->getCode(), 'error_msg' => $e->getMessage());
         }
         // if an error occured, log it
         if (isset($results['error_code'])) {
             self::log('facebook getComments-' . $uid . '-' . $results['error_msg']);
         } elseif ($results) {
             echo 'received ' . count($results) . ' comments from facebook' . "\n";
             $values = array();
             foreach ($results as $row) {
                 if ($feedItem = feed_item_from_id($row['xid'])) {
                     // if album is empty skip it
                     $netUser = new User();
                     if (!$netUser->getByNetworkID(self::getNetwork(), $row['fromid'])) {
                         $netUser = UserHelper::create(null, null, null, null, self::getNetwork(), $row['fromid']);
                     }
                     // format data how wib likes it
                     try {
                         $comments[] = $feedItem->addComment($netUser, $row['text'], $row['time'], self::getNetwork()->getName() . ':' . $row['id']);
                     } catch (Exception $ex) {
                         //If no id, it's likely a dupe; just continue
                     }
                 }
             }
         }
     }
     return;
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:90,代码来源:facebook_wrapper.php


注:本文中的UserHelper::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。