コード例 #1
0
ファイル: Google.php プロジェクト: andrewkrug/repucaution
 function __construct($user_id, $token = null)
 {
     $this->_ci =& get_instance();
     $this->_ci->config->load('social_credentials');
     $mtype = $this->getMediaType();
     $this->_config = Api_key::build_config('google', $this->_ci->config->item($mtype));
     $this->_user_id = $user_id;
     $this->_google = new Google_Client();
     $this->_google->setApplicationName("Script test");
     $this->_google->setClientId($this->_config['client_id']);
     $this->_google->setClientSecret($this->_config['secret']);
     $this->_google->setRedirectUri($this->_config['redirect_uri']);
     $this->_google->setDeveloperKey($this->_config['developer_key']);
     $this->_google->setAccessType('offline');
     if ($mtype == 'youtube') {
         $this->_google->setScopes(array('https://gdata.youtube.com', 'https://www.googleapis.com/auth/userinfo.profile'));
     } elseif ($mtype == 'google_auth' || $mtype == 'google_login') {
         $this->_google->setScopes(array('https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email'));
     } else {
         $this->_google->setScopes(array('https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/plus.me'));
     }
     if (!$token) {
         $this->_token = Access_token::inst()->get_one_by_type('google', $this->_user_id)->to_array();
     } else {
         $this->_token = $token;
     }
 }
コード例 #2
0
 /**
  * Load config and google access token model
  */
 public function __construct()
 {
     parent::__construct($this->website_part);
     $this->load->config('site_config', TRUE);
     $analytics_keys = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
     $this->analytics_settings = array('client_id' => $analytics_keys['client_id'], 'client_secret' => $analytics_keys['secret'], 'redirect_uri' => site_url('settings/analytics/connect'));
     $this->access_token = Access_token::getByTypeAndUserId('googlea', $this->c_user->id);
 }
コード例 #3
0
ファイル: analytics.php プロジェクト: andrewkrug/repucaution
 /**
  * Load config and google access token model
  */
 public function __construct()
 {
     parent::__construct($this->website_part);
     $this->load->config('site_config', TRUE);
     // $this->analytics_settings = $this->config->item('google_app', 'site_config');
     $this->analytics_settings = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
     $this->analytics_settings['client_secret'] = $this->analytics_settings['secret'];
     $this->analytics_settings['redirect_uri'] = site_url('settings/analytics/connect');
     $this->access_token = Access_token::inst()->get_one_by_type('google', $this->c_user->id);
 }
コード例 #4
0
ファイル: piwik.php プロジェクト: andrewkrug/repucaution
 /**
  * Load config and google access token model
  */
 public function __construct()
 {
     parent::__construct($this->website_part);
     $this->piwik_settings = Api_key::build_config('piwik');
     $this->lang->load('piwik_settings', $this->language);
     JsSettings::instance()->add(['i18n' => $this->lang->load('piwik_settings', $this->language)]);
     if (!empty($this->piwik_settings['domain']) && !empty($this->piwik_settings['token'])) {
         $this->piwik = new \VisualAppeal\Piwik($this->piwik_settings['domain'], $this->piwik_settings['token'], "all");
     }
 }
コード例 #5
0
 public function __construct()
 {
     parent::__construct();
     get_instance()->config->load('site_config', TRUE);
     // $api = get_instance()->config->item('google_app', 'site_config');
     // $this->api_key = $api['simple_api_key'];
     $this->api_key = Api_key::value('google', 'developer_key');
     if (empty($this->api_key)) {
         throw new Exception('Setup google api key.');
     }
 }
コード例 #6
0
ファイル: analytics.php プロジェクト: andrewkrug/repucaution
 /**
  * Load config and google access token model
  */
 public function __construct()
 {
     parent::__construct($this->website_part);
     $this->template->set('section', 'analytics');
     $this->load->config('site_config', TRUE);
     $this->lang->load('analytics_settings', $this->language);
     JsSettings::instance()->add(['i18n' => $this->lang->load('analytics_settings', $this->language)]);
     $analytics_keys = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
     $this->analytics_settings = array('client_id' => $analytics_keys['client_id'], 'client_secret' => $analytics_keys['secret'], 'redirect_uri' => site_url('settings/analytics/connect'));
     $this->access_token = Access_token::getByTypeAndUserIdAndProfileId('googlea', $this->c_user->id, $this->profile->id);
 }
コード例 #7
0
ファイル: Twitter.php プロジェクト: andrewkrug/repucaution
 /**
  * @param integer|null $user_id
  * @param array|null $token
  */
 function __construct($user_id, $token)
 {
     $this->_ci =& get_instance();
     $this->_ci->config->load('social_credentials');
     $this->_config = Api_key::build_config('twitter', $this->_ci->config->item('twitter'));
     $this->_user_id = $user_id;
     if (!$token) {
         $this->_token = Access_token::inst()->get_one_by_type('twitter', $this->_user_id)->to_array();
     } else {
         $this->_token = $token;
     }
 }
コード例 #8
0
ファイル: Instagram.php プロジェクト: andrewkrug/repucaution
 /**
  * Construct function
  * Sets the codeigniter instance variable and loads the lang file
  * @param integer|null $user_id
  * @param array|null $token
  */
 function __construct($user_id, $token)
 {
     // Set the CodeIgniter instance variable
     $this->_ci =& get_instance();
     // Load the Instagram API language file
     $this->_ci->config->load('social_credentials');
     $this->_config = Api_key::build_config('instagram', $this->_ci->config->item('instagram'));
     //var_dump($this->_config);die;
     $this->_user_id = $user_id;
     $this->_token = $token;
     $this->access_token = $this->_token['token1'];
     $this->instanceId = $this->_token['instance_id'];
 }
コード例 #9
0
ファイル: Linkedin.php プロジェクト: andrewkrug/repucaution
 /**
  * Method for get access to linkedin
  *
  * @access public
  * @param $user_id id current user
  * @param array|null $token
  * @return Socializer_Linkedin
  */
 function __construct($user_id, $token)
 {
     $this->_ci =& get_instance();
     $this->_ci->config->load('social_credentials');
     $this->_config = Api_key::build_config('linkedin', $this->_ci->config->item('linkedin'));
     $this->_user_id = (string) $user_id;
     $this->_linkedin = new Linkedin($this->_config);
     if (!$token) {
         $this->_token = Access_token::inst()->get_one_by_type('linkedin', $this->_user_id)->to_array();
     } else {
         $this->_token = $token;
     }
 }
コード例 #10
0
ファイル: ga_use.php プロジェクト: andrewkrug/repucaution
 public function __construct($params = array())
 {
     $this->ci =& get_instance();
     $this->ci->load->config('site_config', TRUE);
     // $this->config = $this->ci->config->item('google_app', 'site_config');
     $this->config = Api_key::build_config('google', $this->ci->config->item('google_app', 'site_config'));
     $this->config['client_secret'] = $this->config['secret'];
     $this->ci->load->config('ga_queries', TRUE);
     $this->queries = $this->ci->config->item('queries', 'ga_queries');
     $this->ci->load->library('google_analytics/ga_client');
     if (isset($params['token'])) {
         $this->init($params['token']);
     }
     $this->default_dates = array('from' => '-1 month', 'to' => 'today');
 }
コード例 #11
0
 /**
  * Grab results for single keyword
  * 
  * @param $keyword_array (array) - keyword model arrayed
  * @throws Exception
  */
 public function grabber($keyword_array)
 {
     try {
         $keyword_id = isset($keyword_array['id']) ? $keyword_array['id'] : NULL;
         $keyword = new Keyword($keyword_id);
         if (!$keyword->exists()) {
             throw new Exception('kwid: ' . $keyword_id . ' doesn\'t exist.');
         }
         if ($keyword->is_deleted) {
             throw new Exception('kwid: ' . $keyword->id . ' is set for deletion.');
         }
         $user_additional = User_additional::inst()->get_by_user_and_profile($keyword->user_id, $keyword->profile_id);
         if (!$user_additional->exists()) {
             throw new Exception('No user additional model for user: '******' ; kwid: ' . $keyword->id);
         }
         if (!$user_additional->address_id) {
             throw new Exception('No address id for user: '******'; kwid: ' . $keyword->id);
         }
         $this->load->config('site_config', TRUE);
         // $google_app_config = $this->config->item('google_app', 'site_config');
         $google_app_config = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
         $this->load->library('gls');
         $gls = new Gls();
         // important
         $gls->set(array('key' => $google_app_config['developer_key']));
         $gls->request($keyword->keyword);
         if ($gls->success()) {
             $rank = $gls->location_rank($user_additional->address_id);
             if (is_null($rank)) {
                 throw new Exception('no results for rank. kwid: ' . $keyword->id);
             }
             $keyword_rank = new Keyword_rank();
             $keyword_rank->where(array('keyword_id' => $keyword->id, 'date' => date('Y-m-d')))->get(1);
             $keyword_rank->keyword_id = $keyword->id;
             $keyword_rank->date = date('Y-m-d');
             $keyword_rank->rank = intval($rank);
             $keyword_rank->save();
             log_message('TASK_SUCCESS', __FUNCTION__ . ' > ' . 'GLS Rank grabbed for kwid: ' . $keyword->id . ' -> ' . $rank);
         } else {
             throw new Exception('Google Rank Grabber Error: ' . $gls->error());
         }
     } catch (Exception $e) {
         //echo 'error: '.$e->getMessage().PHP_EOL;
         log_message('TASK_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
         throw $e;
     }
 }
コード例 #12
0
ファイル: piwik.php プロジェクト: andrewkrug/repucaution
 public function __construct()
 {
     parent::__construct($this->website_part);
     $this->lang->load('analytics', $this->language);
     JsSettings::instance()->add(['i18n' => $this->lang->load('analytics', $this->language)]);
     $config = Api_key::build_config('piwik');
     $config['site_id'] = $this->c_user->ifUserHasConfigValue('piwik_site_id');
     if (!empty($config['domain']) && !empty($config['token']) && !empty($config['site_id'])) {
         $this->piwik = new \VisualAppeal\Piwik($config['domain'], $config['token'], $config['site_id']);
     }
     $now = new \DateTime();
     $to_str = $now->format($this->date_format);
     $now->modify('-30 days');
     $from_str = $now->format($this->date_format);
     // default date range
     $this->dates = array('from' => $from_str, 'to' => $to_str);
 }
コード例 #13
0
ファイル: Facebook.php プロジェクト: andrewkrug/repucaution
 /**
  * Construct function
  * Sets the codeigniter instance variable and loads the lang file
  * @param integer|null $user_id
  * @param array|null $token
  */
 function __construct($user_id, $token)
 {
     $this->_ci =& get_instance();
     $this->_ci->config->load('social_credentials');
     $this->_config = Api_key::build_config('facebook', $this->_ci->config->item('facebook'));
     $this->_user_id = $user_id;
     $this->_facebook = new Facebook($this->_config);
     $this->_token = $token;
     if (isset($this->_token['id'])) {
         $this->_facebook->destroySession();
         $this->_facebook->setAccessToken($this->_token['token1']);
         $page = Facebook_Fanpage::inst()->get_selected_page($this->_user_id, $this->_token['id']);
         if ($page->id) {
             $this->_fanpage_id = $page->fanpage_id;
             $this->_profile_id = $page->profile_id;
         }
     }
 }
コード例 #14
0
ファイル: admin_api.php プロジェクト: andrewkrug/repucaution
 public function index()
 {
     if (!empty($_POST)) {
         if ($this->isConfigChangeable()) {
             foreach ($_POST as $post_key => $value) {
                 $parts = explode('/', $post_key);
                 $social = $parts[0];
                 $key = $parts[1];
                 Api_key::inst()->where(array('social' => $social, 'key' => $key))->update('value', $value ? $value : NULL);
             }
             $this->addFlash(lang('api_update_success'), 'success');
         } else {
         }
     }
     $api_keys = Api_key::inst()->get();
     $this->template->set('api_keys', $api_keys);
     $this->template->render();
 }
コード例 #15
0
 public function index()
 {
     $has_empty_api_keys = Api_key::has_empty();
     $cache_dir = APPPATH . 'cache';
     $dashboardLinks = array('admin/admin_users' => lang('manage_customers'), 'admin/manage_accounts' => lang('account_managers'), 'admin/admin_api' => lang('api_keys'), 'admin/manage_plans' => lang('plans_management'), 'admin/payment_settings' => lang('payment_settings'), 'admin/influencers_settings' => lang('influencers_settings'), 'admin/transactions' => lang('payment_transactions'), 'admin/social_settings' => lang('social_settings'));
     if ($this->ion_auth->is_superadmin()) {
         $dashboardLinks['admin/manage_admins'] = lang('admins_management');
         $dashboardLinks['admin/mailchimp'] = lang('export_to_mailchimp');
     }
     //        $this->template->set('has_empty_api_keys', $has_empty_api_keys);
     //        $this->template->set('cache_dir', $cache_dir);
     $this->template->set('dashboard_links', $dashboardLinks);
     if ($has_empty_api_keys) {
         $message = lang('api_keys_error', [site_url('admin/admin_api')]);
         $this->addFlash($message);
     }
     if (!is_writable($cache_dir)) {
         $message = lang('cache_error', [$cache_dir]);
         $this->addFlash($message);
     }
     $this->template->render();
 }
コード例 #16
0
ファイル: tests.php プロジェクト: andrewkrug/repucaution
 public function grank($keyword_id)
 {
     $keyword = new Keyword($keyword_id);
     $user_additional = User_additional::inst()->get_by_user_id($keyword->user_id);
     $this->load->config('site_config', TRUE);
     // $google_app_config = $this->config->item('google_app', 'site_config');
     $google_app_config = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
     $gls = $this->load->library('gls');
     $gls->set(array('key' => $google_app_config['developer_key']));
     $gls->request($keyword->keyword);
     if ($gls->success()) {
         $rank = $gls->location_rank($user_additional->address_id);
         if (is_null($rank)) {
             throw new Exception('No results for rank');
         }
         echo 'Rank: ' . $rank;
     } else {
         throw new Exception('Google Rank Grabber Error: ' . $gls->error());
     }
     echo '<hr>';
     echo '<pre>';
     var_dump($gls->dirty());
 }
コード例 #17
0
ファイル: keywords.php プロジェクト: andrewkrug/repucaution
 /**
  * Autocomplete for company address
  */
 public function google_autocomplete()
 {
     $term = $this->input->get('term');
     $term = trim($term);
     try {
         $developer_key = Api_key::value('google', 'developer_key');
         $gls = $this->load->library('gls');
         $gls->set(array('key' => $developer_key));
         $rows = $gls->autocomplete($term);
         if (!$rows or !isset($rows['predictions'])) {
             throw new Exception();
         }
         $rows = $rows['predictions'];
         $data = array();
         foreach ($rows as $row) {
             $data[] = array('id' => $row['id'], 'label' => $row['description']);
         }
     } catch (Exception $e) {
         exit;
     }
     header('Content-Type: application/json');
     echo json_encode($data);
     exit;
 }
コード例 #18
0
 protected function piwik_load()
 {
     $piwik_config = Api_key::build_config('piwik');
     if (isset($piwik_config['domain'], $piwik_config['site_id'])) {
         $this->template->set('piwik_enabled', true);
         $this->template->set('piwik_domain', $piwik_config['domain']);
         $this->template->set('piwik_site_id', $piwik_config['site_id']);
     } else {
         $this->template->set('piwik_enabled', false);
     }
 }
コード例 #19
0
ファイル: Foursquare.php プロジェクト: andrewkrug/repucaution
 protected function _prepare_url($second = null)
 {
     $venueId = $this->_get_venueid_from_url();
     $keys = Api_key::inst()->value('foursquare');
     $json_url = 'http://api.foursquare.com/v2/venues/' . $venueId;
     if ($second) {
         $json_url .= '/tips';
     }
     $data = array('sort' => 'recent', 'client_id' => $keys['client_id'], 'client_secret' => $keys['client_secret'], 'limit' => 500, 'v' => date('Ymd', now()));
     return $json_url . '?' . http_build_query($data);
 }
コード例 #20
0
ファイル: test.php プロジェクト: andrewkrug/repucaution
 public function getLocation()
 {
     $user_additional = User_additional::inst()->get_by_user_id(3);
     $this->load->config('site_config', TRUE);
     // $google_app_config = $this->config->item('google_app', 'site_config');
     $google_app_config = Api_key::build_config('google', $this->config->item('google_app', 'site_config'));
     $this->load->library('gls');
     $gls = new Gls();
     // important
     $gls->set(array('key' => $google_app_config['developer_key']));
     $gls->request('social');
     if ($gls->success()) {
         $rank = $gls->location_rank($user_additional->address_id);
         echo $rank;
     } else {
         throw new Exception('Google Rank Grabber Error: ' . $gls->error());
     }
 }