public static function httpGetRequest($url) { Requests::register_autoloader(); $headers = array('PAYDUNYA-PUBLIC-KEY' => Paydunya_Setup::getPublicKey(), 'PAYDUNYA-PRIVATE-KEY' => Paydunya_Setup::getPrivateKey(), 'PAYDUNYA-MASTER-KEY' => Paydunya_Setup::getMasterKey(), 'PAYDUNYA-TOKEN' => Paydunya_Setup::getToken(), 'PAYDUNYA-MODE' => Paydunya_Setup::getMode(), 'User-Agent' => "PAYDUNYA Checkout API PHP client v1 aka Neptune"); $request = Requests::get($url, $headers, array('timeout' => 10)); return json_decode($request->body, true); }
/** * 버전정보 페이지입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_admin_config_cbversion_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); Requests::register_autoloader(); $headers = array('Accept' => 'application/json'); $postdata = array('requesturl' => current_full_url(), 'package' => CB_PACKAGE, 'version' => CB_VERSION); $request = Requests::post(config_item('ciboard_check_latest_version'), $headers, $postdata); $view['view']['latest_versions'] = json_decode($request->body, true); if (strtolower(CB_PACKAGE) === 'premium') { $view['view']['latest_version_name'] = $view['view']['latest_versions']['premium_version']; $view['view']['latest_download_url'] = $view['view']['latest_versions']['premium_downloadurl']; } else { $view['view']['latest_version_name'] = $view['view']['latest_versions']['basic_version']; $view['view']['latest_download_url'] = $view['view']['latest_versions']['basic_downloadurl']; } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 어드민 레이아웃을 정의합니다 */ $layoutconfig = array('layout' => 'layout', 'skin' => 'index'); $view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
public function __construct() { // Call the CI_Model constructor parent::__construct(); require 'vendor/autoload.php'; Requests::register_autoloader(); }
public function __construct($counter_id, $counter_key, $api_url = 'http://leads.promotion.bz/api/1.0') { $this->url = $api_url; $this->counter_id = $counter_id; $this->counter_key = $counter_key; \Requests::register_autoloader(); }
function __construct() { parent::__construct(); $this->load->library(array('tank_auth', 'form_validation')); $this->user = $this->tank_auth->get_user_id(); $this->username = $this->tank_auth->get_username(); // Set username if (!$this->user) { $this->session->set_flashdata('response_status', 'error'); $this->session->set_flashdata('message', lang('access_denied')); redirect('auth/login'); } Requests::register_autoloader(); $this->auth_key = config_item('api_key'); // Set our API KEY $this->load->module('layouts'); $this->load->config('rest'); $this->load->library('template'); $this->template->title(lang('settings') . ' - ' . config_item('company_name') . ' ' . config_item('version')); $this->page = lang('settings'); $this->load->model('settings_model', 'settings'); $this->general_setting = '?settings=general'; $this->invoice_setting = '?settings=invoice'; $this->system_setting = '?settings=system'; }
function __construct() { parent::__construct(); $this->load->model('queue_model'); $this->load->library('rest'); Requests::register_autoloader(); }
/** * Class constructor * * @author Ken Auberry <*****@*****.**> */ public function __construct() { parent::__construct(); $this->load->helper('myemsl'); Requests::register_autoloader(); $this->myemsl_ini = read_myemsl_config_file('general'); }
public static function httpGetRequest($url) { Requests::register_autoloader(); $headers = array('MP-Public-Key' => MPower_Setup::getPublicKey(), 'MP-Private-Key' => MPower_Setup::getPrivateKey(), 'MP-Master-Key' => MPower_Setup::getMasterKey(), 'MP-Token' => MPower_Setup::getToken(), 'MP-Mode' => MPower_Setup::getMode(), 'User-Agent' => "MPower Checkout API PHP client v1 aka Don Nigalon"); $request = Requests::get($url, $headers, array('timeout' => 10)); return json_decode($request->body, true); }
public function run() { spl_autoload_register(array('Core', 'autoload'), true, true); Requests::register_autoloader(); if ($this->song_info) { User::save_mediaplay($this->user, $this->song_info); } }
/** * Create a new instance of Sixreps. * @return void */ public function __construct($host = null) { if (!empty($host)) { $this->_host = $host; } include dirname(__FILE__) . '/lib/Requests.php'; Requests::register_autoloader(); }
/** * Configure the api by supplying an object that informs * what payload object to use, what URI to send to, etc. * * @param IHttpConfig $config * @param LoggerInterface $logger */ public function __construct(IHttpConfig $config, LoggerInterface $logger = null) { $this->logger = $logger ?: new NullLogger(); $this->config = $config; \Requests::register_autoloader(); $this->messageFactory = new Payload\BidirectionalMessageFactory($this->config); $this->logRequestUrl(); }
function __construct() { parent::__construct(); $this->load->model('pelayanan/pelayanan_model'); $this->load->model('registrasi/reg_poli_model'); $this->load->library('rest'); Requests::register_autoloader(); }
public function __construct($email, $apikey, $apptitle = '', $module = 'API') { Requests::register_autoloader(); $this->className = get_class($this); $this->email = $email; $this->apikey = $apikey; $this->headers = array('Authorization' => self::API_AUTH_KEYWORD . " email=" . $this->email . "&apikey=" . $this->apikey); $this->data['apptitle'] = $apptitle; $this->data['module'] = $module; }
public function __construct($email, $apikey, $apptitle = '', $module = 'API', $company_id = '') { Requests::register_autoloader(); $this->className = get_class($this); $this->email = $email; $this->apikey = $apikey; $this->company_id = $company_id; $this->headers = array('Authorization' => self::API_AUTH_KEYWORD . " " . http_build_query(array('email' => $this->email, 'apikey' => $this->apikey, 'company_id' => $this->company_id))); $this->data['apptitle'] = $apptitle; $this->data['module'] = $module; }
public function __construct() { parent::__construct(); $this->load->helper(array('application_helper', 'all_registrasi_helper')); $this->load->helper('pelayanan_irj_helper', 'menu_helper'); $this->load->library('form_validation'); $model = array('menu_model', 'emr/input_diagnosa_jmn_model', 'emr/emr_model', 'pelayanan/pelayanan_irna_model', 'pelayanan/ambulan_model', 'kasir/kasir_model', 'kasir/simulasi_tagihan_model'); $this->load->model($model); $this->menu['top_menu'] = TRUE; $this->load->library('rest'); Requests::register_autoloader(); }
public function __construct($token) { //echo 'The class "', __CLASS__, '" was initiated!<br />'; // Include Requests library include 'Requests/Requests.php'; // load Requests internal classes Requests::register_autoloader(); $this->global_webserver = "http://localhost:8000"; // Set up session $this->s = new Requests_Session($this->global_webserver); $this->s->headers['Accept'] = 'application/json'; $this->s->useragent = 'RESTful API [FruityWiFi]'; // Set up login user/pass | token $this->token = $token; }
public function __construct($token) { // Include Requests library include 'Requests/Requests.php'; // load Requests internal classes Requests::register_autoloader(); $this->global_webserver = "http://127.0.0.1:8081"; // Set up session $this->s = new Requests_Session($this->global_webserver); $this->s->headers['Accept'] = 'application/json'; $this->s->useragent = 'Awesomesauce'; // Set up login user/pass $this->username = $username; $this->password = $password; $this->token = $token; }
public function initialize(Controller $c) { switch ($_SERVER['HTTP_HOST']) { case '54.218.113.96': case 'ec2-54-218-113-96.us-west-2.compute.amazonaws.com': case 'novosite.faesa.br': case 'portal.faesa.br': $this->url_service = "http://localhost/faesa/rest/storage"; $this->url_frontend = "http://portal.faesa.br/"; //$this->url_service = "http://site1375796366.hospedagemdesites.ws/app/webroot/rest/storage"; //$this->url_frontend = "http://site1375796366.hospedagemdesites.ws/"; break; case 'faesa.br': case 'www.faesa.br': $this->url_service = "http://www.faesa.br/app/webroot/rest/storage"; $this->url_frontend = "http://www.faesa.br/"; break; } include_once APP . 'Lib/Requests-master/library/Requests.php'; Requests::register_autoloader(); $this->token = Configure::read('token_static'); }
<?php if ($_REQUEST["dupa"] == "jasiukaruzela") { include_once "secret.php"; // First, include Requests include 'Requests-1.6.0/library/Requests.php'; // Next, make sure Requests can load internal classes Requests::register_autoloader(); //error_reporting(0); $im_server = "https://im.gigaset-elements.com"; $status_server = "https://status.gigaset-elements.de/api/v1/status"; $im_api["login"] = "******"; $im_api["info"] = "/identity/api/v1/user/info"; $cloud_server = "https://api.gigaset-elements.com"; $c_api["begin"] = "/api/v1/auth/openid/begin?op=gigaset_elements&return_to=https://my.gigaset-elements.com/"; $c_api["basestations"] = "/api/v1/me/basestations"; $c_api["p"] = "/api/v1/me/basestations/8655B3ECDAAC70BD18218FB4657A132D/endnodes/027c14fe6c/cmd"; //$t = Requests::get($status_server, array('Content-type' => 'application/x-www-form-urlencoded')); //$t = json_decode($t->body); //if($t->isMaintenance==false){echo "ok\n";} $request = Requests::post($im_server . $im_api["login"], array('Content-type' => 'application/x-www-form-urlencoded'), array('email' => $email, 'password' => $password)); $r = json_decode($request->body); //echo $r->reefssid; //$request = Requests::get($im_server.$im_api["info"], array('Content-type' => 'application/x-www-form-urlencoded','Cookie'=>'reefssid='.$r->reefssid)); //var_dump($request); $request = Requests::get($cloud_server . $c_api["begin"], array('Content-type' => 'application/x-www-form-urlencoded', 'Cookie' => 'reefssid=' . $r->reefssid, 'Upgrade-Insecure-Requests' => '1', 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36')); $a = $request->cookies["usertoken"]; //echo $a->value; $request = Requests::get($cloud_server . $c_api["basestations"], array('Content-type' => 'application/x-www-form-urlencoded', 'Cookie' => 'reefssid=' . $r->reefssid, 'Cookie' => 'usertoken=' . $a->value, 'Upgrade-Insecure-Requests' => '1', 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36')); //var_dump($request); $payload = array('name' => 'on');
public function __construct() { Requests::register_autoloader(); }
/** * Check if Requests class is defined, include Requests library if need be * * All HTTP functions should perform that check prior to any operation. This is to avoid * include()-ing all the Requests files on every YOURLS instance disregarding whether needed or not. * * @since 1.7 */ function yourls_http_load_library() { if (!class_exists('Requests', false)) { require_once dirname(__FILE__) . '/Requests/Requests.php'; Requests::register_autoloader(); } }
public function __construct($pdd_token, $oauth_token = null) { $this->pdd_token = $pdd_token; $this->oauth_token = $oauth_token; \Requests::register_autoloader(); }
protected function executeRequest($url, $params, $method = "GET") { Requests::register_autoloader(); if ($method == "GET") { $url = $url . "?" . http_build_query($params); } if ($this->is_hmac) { if ($method == "POST") { $params = json_encode($params); } $headers = $this->createHMACRequestHeaders($url, $params, $method); } else { $headers = $this->createOAuthRequestHeaders(); } try { if ($method == "GET") { return Requests::get($url, $headers); } else { return Requests::post($url, $headers, $params); } } catch (Requests_Exception $e) { print_r($e); } }
public function __construct() { Requests::register_autoloader(); $this->_options = array('timeout' => 100); }
/** * 프론트페이지 레이아웃관리합니다 */ function front($config = array(), $device_view_type = '') { $data = array(); $CI =& get_instance(); if ($CI->uri->segment(1) === config_item('uri_segment_admin') && $CI->uri->segment(2) === 'preview') { return $this->preview($config); } $searchconfig = array('{홈페이지제목}', '{현재주소}', '{회원아이디}', '{회원닉네임}', '{회원레벨}', '{회원포인트}'); $replaceconfig = array($CI->cbconfig->item('site_title'), current_full_url(), $CI->member->item('mem_userid'), $CI->member->item('mem_nickname'), $CI->member->item('mem_level'), $CI->member->item('mem_point')); $page_title = element('page_title', $config) ? element('page_title', $config) : $CI->cbconfig->item('site_meta_title_default'); $meta_description = element('meta_description', $config) ? element('meta_description', $config) : $CI->cbconfig->item('site_meta_description_default'); $meta_keywords = element('meta_keywords', $config) ? element('meta_keywords', $config) : $CI->cbconfig->item('site_meta_keywords_default'); $meta_author = element('meta_author', $config) ? element('meta_author', $config) : $CI->cbconfig->item('site_meta_author_default'); $page_name = element('page_name', $config) ? element('page_name', $config) : $CI->cbconfig->item('site_page_name_default'); $data['page_title'] = $page_title = str_replace($searchconfig, $replaceconfig, $page_title); $data['meta_description'] = $meta_description = str_replace($searchconfig, $replaceconfig, $meta_description); $data['meta_keywords'] = $meta_keywords = str_replace($searchconfig, $replaceconfig, $meta_keywords); $data['meta_author'] = $meta_author = str_replace($searchconfig, $replaceconfig, $meta_author); $data['page_name'] = $page_name = str_replace($searchconfig, $replaceconfig, $page_name); $layoutdirname = $device_view_type === 'mobile' ? element('mobile_layout_dir', $config) : element('layout_dir', $config); if (empty($layoutdirname)) { $layoutdirname = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_layout_default') : $CI->cbconfig->item('layout_default'); } if (empty($layoutdirname)) { $layoutdirname = 'basic'; } $layout = '_layout/' . $layoutdirname; $data['layout_skin_path'] = $layout; $data['layout_skin_url'] = base_url(VIEW_DIR . $data['layout_skin_path']); $layout .= '/'; if (element('layout', $config)) { $layout .= element('layout', $config); } $data['layout_skin_file'] = $layout; $skindir = $device_view_type === 'mobile' ? element('mobile_skin_dir', $config) : element('skin_dir', $config); if (empty($skindir)) { $skindir = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_skin_default') : $CI->cbconfig->item('skin_default'); } if (empty($skindir)) { $skindir = 'basic'; } $skin = ''; if (element('path', $config)) { $skin .= element('path', $config) . '/'; } $skin .= $skindir; $data['view_skin_path'] = $skin; $data['view_skin_url'] = base_url(VIEW_DIR . $data['view_skin_path']); $skin .= '/'; if (element('skin', $config)) { $skin .= element('skin', $config); } $data['view_skin_file'] = $skin; $user_sidebar = $device_view_type === 'mobile' ? element('use_mobile_sidebar', $config) : element('use_sidebar', $config); if ($user_sidebar === '1') { $data['use_sidebar'] = '1'; } elseif ($user_sidebar === '2') { $data['use_sidebar'] = ''; } else { $user_sidebar = $device_view_type === 'mobile' ? $CI->cbconfig->item('mobile_sidebar_default') : $CI->cbconfig->item('sidebar_default'); if ($user_sidebar === '1') { $data['use_sidebar'] = '1'; } elseif ($user_sidebar === '2') { $data['use_sidebar'] = ''; } else { $data['use_sidebar'] = ''; } } $cachename = 'latest_version_from_ciboard_api'; $cachetime = 10800; if (!($result = $CI->cache->get($cachename))) { $CI->load->library('Requests'); $requests = new Requests(); $requests->register_autoloader(); $headers = array('Accept' => 'application/json'); $postdata = array('requesturl' => current_full_url(), 'package' => CB_PACKAGE, 'version' => CB_VERSION); $request = $requests->post(config_item('ciboard_check_latest_version'), $headers, $postdata); $result['latest_versions'] = json_decode($request->body, true); if (strtolower(CB_PACKAGE) === 'premium') { $result['latest_version_name'] = $result['latest_versions']['premium_version']; $result['latest_download_url'] = $result['latest_versions']['premium_downloadurl']; } else { $result['latest_version_name'] = $result['latest_versions']['basic_version']; $result['latest_download_url'] = $result['latest_versions']['basic_downloadurl']; } $CI->cache->save($cachename, $result, $cachetime); } $data['version_latest'] = $result; $mem_id = (int) $CI->member->item('mem_id'); // 현재 접속자 $CI->load->model('Currentvisitor_model'); $currentpage = $page_name ? $page_name : $page_title; $currentpage = $currentpage ? $currentpage : $CI->cbconfig->item('site_title'); $CI->Currentvisitor_model->add_visitor($CI->input->ip_address(), $mem_id, $CI->member->item('mem_nickname'), cdate('Y-m-d H:i:s'), $currentpage, current_full_url(), $CI->agent->referrer(), $CI->agent->agent_string()); if ($CI->cbconfig->item('open_currentvisitor') or $CI->member->is_admin() === 'super') { $minute = (int) $CI->cbconfig->item('currentvisitor_minute'); if ($minute < 1) { $minute = 10; } $curdatetime = cdate('Y-m-d H:i:s', ctimestamp() - $minute * 60); $data['current_visitor_num'] = $CI->Currentvisitor_model->get_current_count($curdatetime); } // 알림 $data['notification_num'] = 0; if ($CI->cbconfig->item('use_notification')) { if ($CI->member->is_member()) { $CI->load->model('Notification_model'); $data['notification_num'] = $CI->Notification_model->unread_notification_num($mem_id); } } // 메뉴관리 $CI->load->model('Menu_model'); $data['menu'] = $CI->Menu_model->get_all_menu($device_view_type); //팝업관리 $CI->load->library('popuplib'); $data['popup'] = $CI->popuplib->display_popup(); return $data; }
public function us_fan_counts() { header('content-type: application/json'); $ajax_debug = UltimateSocialDeux::opt('us_ajax_debug', false); if (wp_verify_nonce($_REQUEST['nonce'], 'us_nonce') || $ajax_debug) { if (!class_exists('Requests')) { require_once plugin_dir_path(__FILE__) . '/includes/Requests.php'; Requests::register_autoloader(); } $args = $_REQUEST['args'] ? $_REQUEST['args'] : die('Args not set'); $args = urldecode(stripslashes($args)); $args = json_decode($args, true); $option = maybe_unserialize(get_option('us_fan_counts', array())); $json = array(); $networks = explode(',', $args['networks']); $networks = array_keys(array_flip($networks)); $timestamp = time(); foreach ($networks as $key => $network) { $option[$network]['count'] = isset($option[$network]['count']) ? $option[$network]['count'] : 0; $json[$network]['count'] = $option[$network]['count']; $option[$network]['timestamp'] = $timestamp; $id = ''; $key = ''; $secret = ''; $api = ''; $app = ''; $user = ''; $name = ''; $username = ''; switch ($network) { case 'facebook': $app_token = UltimateSocialDeux::opt('us_facebook_token'); $fb_token = $app_token ? "?access_token=" . $app_token : ''; $id = UltimateSocialDeux::opt('us_facebook_id'); if ($id) { $requests[$network] = array('url' => "https://graph.facebook.com/" . $id . $fb_token); } break; case 'twitter': $id = UltimateSocialDeux::opt('us_twitter_id'); $key = UltimateSocialDeux::opt('us_twitter_key'); $secret = UltimateSocialDeux::opt('us_twitter_secret'); if ($id && $key && $secret) { $token = get_option('us_fan_count_twitter_token'); if (!$token) { $credentials = $key . ':' . $secret; $encode = base64_encode($credentials); $args = array('method' => 'POST', 'httpversion' => '1.1', 'blocking' => true, 'headers' => array('Authorization' => 'Basic ' . $encode, 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'), 'body' => array('grant_type' => 'client_credentials')); add_filter('https_ssl_verify', '__return_false'); $response = wp_remote_post('https://api.twitter.com/oauth2/token', $args); $keys = json_decode(wp_remote_retrieve_body($response)); if (!isset($keys->errors) && $keys) { update_option('us_fan_count_twitter_token', $keys->access_token); $token = $keys->access_token; } } $requests[$network] = array('url' => 'https://api.twitter.com/1.1/users/show.json?screen_name=' . $id, 'headers' => array('Authorization' => "Bearer {$token}")); } break; case 'google': $id = UltimateSocialDeux::opt('us_google_id'); $key = UltimateSocialDeux::opt('us_google_key'); if ($key && $id) { $requests[$network] = array('url' => "https://www.googleapis.com/plus/v1/people/" . $id . "?key=" . $key); } break; case 'behance': $id = UltimateSocialDeux::opt('us_behance_id'); $api = UltimateSocialDeux::opt('us_behance_api'); if ($id && $api) { $requests[$network] = array('url' => "http://www.behance.net/v2/users/" . $id . "?api_key=" . $api); } break; case 'delicious': $id = UltimateSocialDeux::opt('us_delicious_id'); if ($id) { $requests[$network] = array('url' => "http://feeds.delicious.com/v2/json/userinfo/" . $id); } break; case 'linkedin': $id = UltimateSocialDeux::opt('us_linkedin_id'); $app = UltimateSocialDeux::opt('us_linkedin_app'); $api = UltimateSocialDeux::opt('us_linkedin_api'); if (!class_exists('LinkedIn')) { require_once plugin_dir_path(__FILE__) . 'includes/linkedin/linkedin.php'; } if (!class_exists('OAuthServer')) { require_once plugin_dir_path(__FILE__) . 'includes/OAuth/OAuth.php'; } if ($id && $api && $id) { $count = 0; $opt = array('appKey' => $app, 'appSecret' => $api, 'callbackUrl' => ''); $api_call = new LinkedIn($opt); $response = $api_call->company(trim('universal-name=' . $id . ':(num-followers)')); if ($ajax_debug) { print_r($response); } if (false !== $response['success']) { $company = new SimpleXMLElement($response['linkedin']); if (isset($company->{'num-followers'})) { $count = intval(current($company->{'num-followers'})); } } $option[$network]['count'] = $count; $json[$network]['count'] = $count; } break; case 'youtube': $id = UltimateSocialDeux::opt('us_youtube_id'); if ($id) { $requests[$network] = array('url' => "http://gdata.youtube.com/feeds/api/users/" . $id . "?alt=json"); } break; case 'soundcloud': $id = UltimateSocialDeux::opt('us_soundcloud_id'); $user = UltimateSocialDeux::opt('us_soundcloud_username'); if ($id && $user) { $requests[$network] = array('url' => 'http://api.soundcloud.com/users/' . $user . '.json?client_id=' . $id); } break; case 'vimeo': $id = UltimateSocialDeux::opt('us_vimeo_id'); if ($id) { $requests[$network] = array('url' => "http://vimeo.com/api/v2/channel/" . $id . "/info.json"); } break; case 'dribbble': $id = UltimateSocialDeux::opt('us_dribbble_id'); if ($id) { $requests[$network] = array('url' => "http://api.dribbble.com/" . $id); } break; case 'github': $id = UltimateSocialDeux::opt('us_github_id'); if ($id) { $requests[$network] = array('url' => "https://api.github.com/users/" . $id); } break; case 'envato': $id = UltimateSocialDeux::opt('us_envato_id'); if ($id) { $requests[$network] = array('url' => "http://marketplace.envato.com/api/edge/user:"******".json"); } break; case 'instagram': $api = UltimateSocialDeux::opt('us_instagram_api'); $id = explode(".", $api); if ($api && $id) { $requests[$network] = array('url' => "https://api.instagram.com/v1/users/" . $id[0] . "/?access_token=" . $api); } break; case 'mailchimp': $name = UltimateSocialDeux::opt('us_mailchimp_name'); $api = UltimateSocialDeux::opt('us_mailchimp_api'); $count = 0; if ($name && $api) { if (!class_exists('MCAPI')) { require_once plugin_dir_path(__FILE__) . 'includes/MCAPI.class.php'; } $api = new MCAPI($api); $retval = $api->lists(); if ($ajax_debug) { print_r($retval); } if (count($retval['data']) > 0) { foreach ($retval['data'] as $list) { if ($list['name'] == $name) { $count = intval($list['stats']['member_count']); break; } } } } $option[$network]['count'] = intval($count); $json[$network]['count'] = intval($count); break; case 'vkontakte': $id = UltimateSocialDeux::opt('us_vkontakte_id'); if ($id) { $requests[$network] = array('url' => "http://api.vk.com/method/groups.getById?gid=" . $id . "&fields=members_count"); } break; case 'pinterest': $username = UltimateSocialDeux::opt('us_pinterest_username'); if ($username) { $requests[$network] = array('url' => 'http://www.pinterest.com/' . $username . '/'); } break; case 'flickr': $id = UltimateSocialDeux::opt('us_flickr_id'); $api = UltimateSocialDeux::opt('us_flickr_api'); if ($id && $api) { $requests[$network] = array('url' => "https://api.flickr.com/services/rest/?method=flickr.groups.getInfo&api_key=" . $api . "&group_id=" . $id . "&format=json&nojsoncallback=1"); } break; case 'feedpress': $manual = intval(UltimateSocialDeux::opt('us_feedpress_manual', 0)); $url = UltimateSocialDeux::opt('us_feedpress_url'); if (filter_var($url, FILTER_VALIDATE_URL)) { $requests[$network] = array('url' => $url); } if ($manual) { $option[$network]['count'] = $manual; $json[$network]['count'] = $manual; } break; default: unset($option[$network]); unset($json[$network]); break; } } $responses = !empty($requests) ? Requests::request_multiple($requests) : die('No requests sent.'); foreach ($responses as $network => $data) { switch ($network) { case 'facebook': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['likes']); $json[$network]['count'] = intval($content['likes']); } break; case 'twitter': case 'soundcloud': case 'dribbble': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['followers_count']); $json[$network]['count'] = intval($content['followers_count']); } break; case 'google': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['circledByCount']); $json[$network]['count'] = intval($content['circledByCount']); } break; case 'behance': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['user']['stats']['followers']); $json[$network]['count'] = intval($content['user']['stats']['followers']); } break; case 'delicious': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content[2]['n']); $json[$network]['count'] = intval($content[2]['n']); } break; case 'youtube': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['entry']['yt$statistics']['subscriberCount']); $json[$network]['count'] = intval($content['entry']['yt$statistics']['subscriberCount']); } break; case 'vimeo': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['total_subscribers']); $json[$network]['count'] = intval($content['total_subscribers']); } break; case 'github': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['followers']); $json[$network]['count'] = intval($content['followers']); } break; case 'envato': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['user']['followers']); $json[$network]['count'] = intval($content['user']['followers']); } break; case 'instagram': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['data']['counts']['followed_by']); $json[$network]['count'] = intval($content['data']['counts']['followed_by']); } break; case 'vkontakte': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['response'][0]['members_count']); $json[$network]['count'] = intval($content['response'][0]['members_count']); } break; case 'pinterest': if (isset($responses[$network]->body)) { $html = $responses[$network]->body; if ($ajax_debug) { print_r($html); } $doc = new DOMDocument(); @$doc->loadHTML($html); $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if ($meta->getAttribute('name') == 'pinterestapp:followers') { $count = intval($meta->getAttribute('content')); break; } } $option[$network]['count'] = $count; $json[$network]['count'] = $count; } break; case 'flickr': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['group']['members']['_content']); $json[$network]['count'] = intval($content['group']['members']['_content']); } break; case 'feedpress': if (isset($responses[$network]->body)) { $content = $responses[$network]->body; if ($ajax_debug) { print_r($content); } $content = json_decode($content, true); $option[$network]['count'] = intval($content['subscribers']) + $manuel; $json[$network]['count'] = intval($content['subscribers']) + $manuel; } break; } } maybe_serialize(update_option('us_fan_counts', $option)); echo str_replace('\\/', '/', json_encode($json)); } else { die('Nonce not verified'); } die; }
public function __construct() { import('Common.Util.Requests'); \Requests::register_autoloader(); }
private static function phpGetLocation($lat, $lng) { require "lib/Requests.php"; Requests::register_autoloader(); $respone = Requests::get("http://maps.googleapis.com/maps/api/geocode/json?latlng={$lat},{$lng}&sensor=true")->body; return $respone; }
public function beforeFilter() { $this->set('relativepath', $this->relative_url()); if ($this->action == 'add') { $this->set('save_shortcut', true); } App::uses('Requests', '/Lib/Requests-master/library'); $this->set('logged_user', $this->Auth->user()); Requests::register_autoloader(); $this->token_static = Configure::read('token_static'); $this->layout = 'lay'; $this->set('current_action', array($this->name, $this->action)); // // // // ACL // // // // $aco_path = join('/',array( 'controllers', $this->name , $this->action )); // // $permissions_xml = APP.'Acl/permissions.xml'; // // $xmlstring = file_get_contents( $permissions_xml ); // // $currentchecksum=md5($xmlstring); // // if( $currentchecksum != file_get_contents(APP.'Acl/checksum.txt') ){ // // $xml = simplexml_load_string( $xmlstring ); // // $this->acotree=array(); // // $this->loadModel('ArosAco'); // // $this->Acl->Aco->deleteAll('1=1'); // $this->ArosAco->deleteAll('1=1'); // // foreach( $xml->permission_set as $p){ // // $model = (string)$p->attributes()->model; // $foreign_key = (string)$p->attributes()->foreign_key; // // foreach ($p->allow as $allow) { // $currentaco=(string)$allow->attributes()->aco; // $this->createAcoNode($currentaco); // // $this->Acl->allow( array('model' => $model, 'foreign_key' => $foreign_key) , $currentaco ); // } // // foreach ($p->deny as $deny) { // $currentaco=(string)$deny->attributes()->aco; // $this->createAcoNode($currentaco); // // $this->Acl->deny( array('model' => $model, 'foreign_key' => $foreign_key), $currentaco ); // } // } // // file_put_contents('../Acl/checksum.txt', $currentchecksum ); // } // // if(in_array($this->action, $this->public_actions)){ // //ação é publica, pode acessar // return true; // } // // $aro_to_check=array( 'model'=>'Group' , 'foreign_key'=>$this->Auth->user('group_id')); // // $allowed=true; // // if( $this->Acl->Aro->findByModelAndForeignKey( $aro_to_check['model'] , $aro_to_check['foreign_key'] ) ){ // // if(!$this->Acl->Aco->node($aco_path)){ // // //checando nos parents pra ver se tem permissao // $aco_array = explode('/', $aco_path); // array_pop($aco_array); // // $allowed=false; // // while(count($aco_array)){ // // $current_aco_path = join( '/' , $aco_array ); // // if( $this->Acl->Aco->node( $current_aco_path ) ) { // // if( $this->Acl->check( $aro_to_check , $current_aco_path ) ){ // $allowed=true; // break; // }else{ // $allowed=false; // break; // } // // } // // array_pop($aco_array); // } // // }else if( ! $this->Acl->check( $aro_to_check , $aco_path ) ){ // $allowed=false; // } // }else{ // // $this->redirect(array('controller'=>'Autenticacao','action'=>'index')); // // return false; // } // // if( !$allowed ) throw new Exception('Você não possui permissão para acessar esta página'); // // // // // // FIM ACL // // }