コード例 #1
0
ファイル: RestCrawl.php プロジェクト: httvncoder/151722441
 public function getAdShareCount()
 {
     $records = AdShareCount::whereRaw('status = ? AND crawl = ?', array(1, false))->take(100)->get();
     if (!count($records)) {
         AdShareCount::all()->update(array('crawl' => false));
         return Response::json(array('status' => 'error'), 500);
     }
     $continue = true;
     foreach ($records as $record) {
         if ($record->ad_id) {
             if ($continue) {
                 $link = Ad::get_ad_link($record->ad_id);
                 if (!isset($obj->Facebook)) {
                     $continue = false;
                     return false;
                 }
                 $obj = AdShareCount::get_obj_share_count($link);
                 $record->share_count = $obj->Facebook->share_count;
                 $record->comment_count = $obj->Facebook->comment_count;
                 $record->like_count = $obj->Facebook->like_count;
                 $record->gp_count = $obj->GooglePlusOne;
                 $record->tw_count = $obj->Twitter;
                 $record->pin_count = $obj->Pinterest;
                 $record->crawl = true;
                 $record->save();
             }
         }
     }
     return Response::json(array('status' => 'success'), 200);
 }
コード例 #2
0
ファイル: Ad.php プロジェクト: httvncoder/151722441
 public function afterCreate()
 {
     // Insert ad link for crawl share sns count information
     $ad_id = $this->attributes['id'];
     if (empty($ad_id)) {
         return false;
     }
     $link = self::get_ad_link($ad_id);
     $record = AdShareCount::where('ad_id', '=', $ad_id)->first();
     if (!$record) {
         $record = new AdShareCount();
         $record->ad_id = $ad_id;
     }
     $record->save();
 }