コード例 #1
1
ファイル: facebook.php プロジェクト: sandulungu/StarLight
 public function graph($objectId = 'me', $params = array())
 {
     if (empty($objectId)) {
         return;
     }
     $params += array('decode' => true);
     $decode = $params['decode'];
     unset($params['decode']);
     App::import('Core', 'HttpSocket');
     $socket = new HttpSocket();
     $protocol = SlConfigure::read('Api.facebook.secure') && SlConfigure::read('Sl.options.sslTransport') ? 'https' : 'http';
     $result = $socket->get("{$protocol}://graph.facebook.com/{$objectId}", $this->accessToken ? $params + array('access_token' => $this->accessToken) : $params);
     return $decode ? json_decode($result, true) : $result;
 }
コード例 #2
0
ファイル: CensorshipModeTest.php プロジェクト: k1low/postman
 /**
  * test_Censorship
  *
  */
 public function test_Censorship()
 {
     $hash = $this->hash;
     $to = 'to+' . $hash . '@mailback.me';
     Configure::write('Postman.censorship.mode', true);
     Configure::write('Postman.censorship.config', array('transport' => 'Smtp', 'from' => array('*****@*****.**' => 'from'), 'to' => $to, 'host' => 'mail.mailback.me', 'port' => 25, 'timeout' => 30, 'log' => false, 'charset' => 'utf-8', 'headerCharset' => 'utf-8'));
     $message = 'Censored';
     $expect = $message;
     $this->email->subject('メールタイトル');
     $this->email->send($expect);
     sleep(15);
     $url = 'http://mailback.me/to/' . $hash . '.body';
     App::uses('HttpSocket', 'Network/Http');
     $HttpSocket = new HttpSocket();
     $results = $HttpSocket->get($url, array());
     $body = trim(str_replace(array("\r\n", "\n", ' '), '', $results->body));
     $message = trim(str_replace(array("\r\n", "\n", ' '), '', $message));
     $this->assertIdentical($results->code, '200');
     $this->assertIdentical($body, $message);
     // CC
     $ccUrl = 'http://mailback.me/to/unknown-cc-' . $hash . '.body';
     $results = $HttpSocket->get($ccUrl, array());
     $this->assertContains('404', $results->body);
     // BCC
     $bccUrl = 'http://mailback.me/to/unknown-bcc-' . $hash . '.body';
     $results = $HttpSocket->get($bccUrl, array());
     $this->assertContains('404', $results->body);
 }
コード例 #3
0
ファイル: update_controller.php プロジェクト: rchavik/20Couch
 function download()
 {
     $result = array('success' => true, 'error' => null);
     $home = Configure::read('20Couch.home');
     App::import('Core', array('HttpSocket', 'File'));
     $Http = new HttpSocket();
     $Setting = ClassRegistry::init('Setting');
     $url = sprintf('%s/registrations/direct/%s/' . Configure::read('Update.file'), $home, $Setting->find('value', 'registration_key'));
     $latest = $Http->get($url);
     if ($latest === false || $Http->response['status']['code'] != 200) {
         if ($Http->response['status']['code'] == 401) {
             $msg = 'Invalid registration key';
         } else {
             $msg = 'Unable to retrieve latest file from ' . $home;
         }
         $this->log($url);
         $this->log($Http->response);
         $result = array('success' => false, 'error' => $msg);
         $this->set('result', $result);
         return;
     }
     $File = new File(TMP . Configure::read('Update.file'), false);
     $File->write($latest);
     $File->close();
     $latestChecksum = trim($Http->get($home . '/checksum'));
     $yourChecksum = sha1_file(TMP . Configure::read('Update.file'));
     if ($yourChecksum != $latestChecksum) {
         $result = array('success' => false, 'error' => 'Checksum doesn\'t match (' . $yourChecksum . ' vs ' . $latestChecksum . ')');
         $this->set('result', $result);
         return;
     }
     $result = array('success' => true, 'error' => null);
     $this->set('result', $result);
 }
コード例 #4
0
 public function decrypt()
 {
     while (empty($md5)) {
         $md5 = $this->in('Ingrese el Hash a buscar');
     }
     $HttpSocket = new HttpSocket();
     $md5 = trim($md5);
     if (strlen($md5) !== 32) {
         return $this->out('Hash invalido');
     }
     $matches = array();
     $html = $HttpSocket->get($this->_url);
     $pattern = '/<input type="hidden" name="a" value="(.*)">/Uis';
     preg_match_all($pattern, $html->body, $matches, PREG_SET_ORDER);
     if (empty($matches[0][1])) {
         return $this->out('El servidor no responde');
     }
     $a = $matches[0][1];
     $rest = $this->postDataViaCurl($HttpSocket, $md5, $a);
     do {
         $this->out('..');
         sleep(1);
     } while ($rest->code === null);
     $returnArray = array();
     $pattern2 = '/Found (.*) <b>(.*)<\\/b><\\/span>/Uis';
     preg_match_all($pattern2, $rest, $returnArray, PREG_SET_ORDER);
     if (empty($returnArray[0][2])) {
         return $this->out('El servidor no responde');
     }
     $nt = trim(strip_tags($returnArray[0][2]));
     if (empty($nt)) {
         return false;
     }
     $this->out('Contraseña desencriptada: <info>' . $nt . '</info>');
 }
コード例 #5
0
 /**
  * Perform the request to AWS
  *
  * @return mixed array of the resulting request or false if unable to contact server
  * @access private
  */
 function __request()
 {
     $this->_request = $this->__signQuery();
     $retval = $this->Http->get($this->_request);
     $retval = Set::reverse(new Xml($retval));
     return $retval;
 }
コード例 #6
0
 public function getStatus($code)
 {
     App::import('Core', 'HttpSocket');
     $HttpSocket = new HttpSocket(array('timeout' => $this->timeout));
     $response = $HttpSocket->get($this->pgURI . $code, "email={$__config['email']}&token={$__config['token']}");
     return $this->__status($response);
 }
コード例 #7
0
 public function maestro($key = null)
 {
     if ($key != 'secret') {
         die('sorry');
     }
     App::uses('HttpSocket', 'Network/Http');
     $httpSocket = new HttpSocket();
     $yesterday = date("Y-m-d H:i:s", strtotime("-1 day"));
     // print_r($yesterday);
     // die;
     $products = $this->Product->find('all', array('recursive' => -1, 'conditions' => array('Product.user_id' => 11, 'Product.active' => 1, 'Product.stock_updated <' => $yesterday), 'order' => 'RAND()', 'limit' => 20));
     foreach ($products as $product) {
         //sleep(1);
         $response = $httpSocket->get('https://www.maestrolico.com/api/checkstockstatus.asp?distributorid=117&productid=' . $product['Product']['vendor_sku']);
         echo '<br /><hr><br />';
         echo $product['Product']['name'] . ' - ' . $product['Product']['vendor_sku'];
         echo '<br /><br />';
         debug($response['body']);
         $update = explode('|', $response['body']);
         debug($update);
         debug(date('H:i:s'));
         $data['Product']['id'] = $product['Product']['id'];
         $data['Product']['stock'] = $update[1];
         $data['Product']['stock_updated'] = date('Y-m-d H:i:s');
         $this->Product->save($data, false);
     }
     die('end');
 }
コード例 #8
0
 function admin_callback()
 {
     $endpoint = $this->request->query['openid_op_endpoint'];
     $query = array();
     $keys = array('openid.ns', 'openid.mode', 'openid.op_endpoint', 'openid.response_nonce', 'openid.return_to', 'openid.assoc_handle', 'openid.signed', 'openid.sig', 'openid.identity', 'openid.claimed_id', 'openid.ns.ext1', 'openid.ext1.mode', 'openid.ext1.type.firstname', 'openid.ext1.value.firstname', 'openid.ext1.type.email', 'openid.ext1.value.email', 'openid.ext1.type.lastname', 'openid.ext1.value.lastname');
     foreach ($keys as $key) {
         $underscoreKey = str_replace('.', '_', $key);
         if (isset($this->params['url'][$underscoreKey])) {
             $query[$key] = $this->params['url'][$underscoreKey];
         }
     }
     $query['openid.mode'] = 'check_authentication';
     $Http = new HttpSocket();
     $response = $Http->get($this->request->query['openid_op_endpoint'] . '?' . http_build_query($query));
     if (strpos($response, 'is_valid:true') === false) {
         return $this->redirect($this->Auth->loginAction);
     }
     $url = $this->params['url'];
     if (isset($url['openid_mode']) && $url['openid_mode'] == 'cancel') {
         return $this->redirect($this->Auth->redirect());
     }
     $user = array('id' => $url['openid_ext1_value_email'], 'name' => $url['openid_ext1_value_firstname'] . ' ' . $url['openid_ext1_value_lastname'], 'email' => $url['openid_ext1_value_email']);
     $this->__callback($user);
     $this->Session->write(AuthComponent::$sessionKey, $user);
     $this->set('redirect', $this->Auth->redirect());
 }
コード例 #9
0
 /**
  * Perform the request to AWS
  *
  * @return mixed array of the resulting request or false if unable to contact server
  */
 private function __request()
 {
     $this->_request = $this->__signQuery();
     $this->__requestLog[] = $this->_request;
     $retval = $this->Http->get($this->_request);
     return Set::reverse(new Xml($retval));
 }
コード例 #10
0
 function index()
 {
     App::import('Core', 'HttpSocket');
     $HttpSocketPr = new HttpSocket();
     // 		$results = $HttpSocketPr->get('https://www.google.com.mx/search', 'q=php');
     $HttpSocketPr->get('http://anonymouse.org/cgi-bin/anon-www.cgi/http://187.141.67.234/projections/users/login');
     // 		returns html for Google's search results for the query "cakephp"
     if (!empty($HttpSocketPr->response['cookies']['CAKEPHP']['path']) and $HttpSocketPr->response['cookies']['CAKEPHP']['path'] === '/projections') {
         debug($HttpSocketPr->response['cookies']);
         var_dump('Projections External site is OK');
     } else {
         var_dump('Projections External site is Down');
     }
     $HttpSocketGst = new HttpSocket();
     $HttpSocketGst->get('http://anonymouse.org/cgi-bin/anon-www.cgi/http://187.141.67.234/gst/users/login');
     if (!empty($HttpSocketGst->response['cookies']['CAKEPHP']['path']) and $HttpSocketGst->response['cookies']['CAKEPHP']['path'] === '/gst') {
         debug($HttpSocketGst->response['cookies']);
         var_dump('Gst External site is OK');
     } else {
         var_dump('Gst External site is Down');
     }
     // 		$HttpSocketFm = new HttpSocket();
     // 		$HttpSocketFm->get('http://localhost/smb/class/filemanager/filemanager.php');
     //
     // 		$this->set('fm',$HttpSocketFm->response['body']);
     $this->FieldView->recursive = 0;
     $this->set('fieldViews', $this->paginate());
 }
コード例 #11
0
ファイル: http_socket_lib.php プロジェクト: robksawyer/tools
 /**
  * fetches url with curl if available
  * fallbacks: cake and php
  * note: expects url with json encoded content
  * @access private
  **/
 public function fetch($url, $agent = 'cakephp http socket lib')
 {
     if ($this->use['curl'] && function_exists('curl_init')) {
         $this->debug = 'curl';
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_USERAGENT, $agent);
         $response = curl_exec($ch);
         $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close($ch);
         if ($status != '200') {
             $this->setError('Error ' . $status);
             return false;
         }
         return $response;
     } elseif ($this->use['cake'] && App::import('Core', 'HttpSocket')) {
         $this->debug = 'cake';
         $HttpSocket = new HttpSocket(array('timeout' => 5));
         $response = $HttpSocket->get($url);
         if (empty($response)) {
             //TODO: status 200?
             return false;
         }
         return $response;
     } elseif ($this->use['php'] || true) {
         $this->debug = 'php';
         $response = file_get_contents($url, 'r');
         //TODO: status 200?
         if (empty($response)) {
             return false;
         }
         return $response;
     }
 }
コード例 #12
0
 function main()
 {
     App::import('HttpSocket');
     $site = isset($this->args['0']) ? $this->args['0'] : null;
     while (empty($site)) {
         $site = $this->in("What site would you like to crawl?");
         if (!empty($site)) {
             break;
         }
         $this->out("Try again.");
     }
     $Socket = new HttpSocket();
     $links = array();
     $start = 0;
     $num = 100;
     do {
         $r = $Socket->get('http://www.google.com/search', array('hl' => 'en', 'as_sitesearch' => $site, 'num' => $num, 'filter' => 0, 'start' => $start));
         if (!preg_match_all('/href="([^"]+)" class="?l"?/is', $r, $matches)) {
             die($this->out('Error: Could not parse google results'));
         }
         $links = array_merge($links, $matches[1]);
         $start = $start + $num;
     } while (count($matches[1]) >= $num);
     $links = array_unique($links);
     $this->out(sprintf('-> Found %d links on google:', count($links)));
     $this->hr();
     $this->out(join("\n", $links));
 }
コード例 #13
0
 /**
  * _get()
  *
  * @param mixed $url
  * @param mixed $params
  * @return string
  */
 protected function _get($url, $params)
 {
     $Socket = new HttpSocket();
     $response = $Socket->get($url, $params);
     //$file = TMP . Inflector::slug($url) . '.json';
     //file_put_contents($file, $response->body);
     return isset($response->body) ? $response->body : '';
 }
コード例 #14
0
ファイル: ClientController.php プロジェクト: trice4/BlogTest
 public function request_view($id)
 {
     $link = Router::url('/', true) . 'rest_posts/' . $id . '.json';
     $data = null;
     $httpSocket = new HttpSocket();
     $response = $httpSocket->get($link, $data);
     $this->set('response_code', $response->code);
     $this->set('response_body', $response->body);
     $this->render('/Client/request_response');
 }
コード例 #15
0
 public function request_view($id)
 {
     // remotely post the information to the server
     $link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . 'rest_tasks/' . $id . '.json';
     $data = null;
     $httpSocket = new HttpSocket();
     $response = $httpSocket->get($link, $data);
     $this->set('response_code', $response->code);
     $this->set('response_body', $response->body);
     $this->render('/Client/request_response');
 }
コード例 #16
0
ファイル: twitter.php プロジェクト: shin1x1/findTwitter
 /**
  * paginate
  *
  * @param  mixed $conditions
  * @param  mixed $fields
  * @param  mixed $order
  * @param  integer $limit
  * @param  integer $page
  * @param  integer $recursive
  * @param  array $extract
  * @return array
  */
 public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra)
 {
     $HttpSocket = new HttpSocket();
     $query = array('q' => Set::extract('q', $conditions), 'page' => $page, 'rpp' => $limit, 'lang' => Set::extract('lang', $conditions));
     $ret = $HttpSocket->get(self::API_SEARCH, $query);
     if ($ret) {
         $Xml = new Xml($ret);
         return $Xml->toArray();
     }
     return array();
 }
コード例 #17
0
 /**
  * Se inicia la libreria, éste se conecta al servicio y guarda los valores para su posterior uso
  *
  * @return boolean Una vez iniciada o ya iniciada la libreria
  */
 public static function init()
 {
     if (self::$__init) {
         return true;
     }
     $HttpSocket = new HttpSocket();
     $response = $HttpSocket->get("http://indicadoresdeldia.cl/webservice/indicadores.json");
     if ($response->isOk()) {
         self::$__indicadores = json_decode($response->body, true);
     }
     return self::$__init = true;
 }
コード例 #18
0
ファイル: app_model.php プロジェクト: slywalker/study_collect
 protected function getTitle($url)
 {
     if (!empty($url)) {
         $HttpSocket = new HttpSocket();
         $results = $HttpSocket->get($url);
         $results = mb_convert_encoding($results, Configure::read('App.encoding'), 'auto');
         preg_match('/<title>([^<]*)<\\/title>/i', $results, $matchs);
         if (isset($matchs[1])) {
             return mb_trim($matchs[1]);
         }
     }
     return '';
 }
コード例 #19
0
ファイル: FbController.php プロジェクト: hungnt88/5stars-1
 public function getDailyCode($access_token=null, $day=null)
 {
     $this->autoLayout = false;
     $this->autoRender = false;
     if (isset($access_token) || isset($day)) {
         $HttpSocket = new HttpSocket(array('ssl_verify_peer' => false));
         $url = 'http://bakhi.5stars.vn/fb/dailyCode/' . $access_token . '/' . $day;
         $response = $HttpSocket->get($url);
         return $response->body;
     } else {
         return '{"error":"Thiếu dữ liệu"}';
     }
 }
コード例 #20
0
 public function googleAuth($data)
 {
     $HttpSocket = new HttpSocket();
     $googleAuthCheck = $HttpSocket->get('https://www.googleapis.com/oauth2/v3/tokeninfo', array('id_token' => $data['token']));
     $googleAuthCheckBody = json_decode($googleAuthCheck['body'], true);
     $resposta = array('name' => isset($googleAuthCheckBody['name']) ? $googleAuthCheckBody['name'] : "", 'family_name' => isset($googleAuthCheckBody['family_name']) ? $googleAuthCheckBody['family_name'] : "", 'given_name' => isset($googleAuthCheckBody['given_name']) ? $googleAuthCheckBody['given_name'] : "", 'email' => isset($googleAuthCheckBody['email']) ? $googleAuthCheckBody['email'] : "", 'imageUrl' => isset($googleAuthCheckBody['picture']) ? $googleAuthCheckBody['picture'] : "", 'profileId' => isset($googleAuthCheckBody['sub']) ? $googleAuthCheckBody['sub'] : "", 'signin' => false, 'approved' => false, 'token' => $data['token']);
     $usuario = $this->Usuario->findByEmail($resposta['email']);
     if ($usuario) {
         $resposta['signin'] = true;
         $resposta['approved'] = $usuario['Usuario']['aprovado'] == '1' ? true : false;
     }
     return $resposta;
 }
コード例 #21
0
ファイル: Chemical.php プロジェクト: egonw/OSDB
 /**
  * Get a property of a chemical
  * List of proprties available at
  * http://pubchem.ncbi.nlm.nih.gov/pug_rest/PUG_REST.html#_Toc409516770
  * @param $props
  * @param $cid
  * @return bool
  */
 public function property($props, $cid)
 {
     $HttpSocket = new HttpSocket();
     $url = $this->path . 'cid/' . rawurlencode($cid) . '/property/' . $props . '/JSON';
     $json = $HttpSocket->get($url);
     //echo $url;exit;
     $meta = json_decode($json['body'], true);
     if (isset($meta['Fault'])) {
         return false;
     } else {
         return $meta['PropertyTable']['Properties'][0];
     }
 }
コード例 #22
0
 /**
  * Downloads a given url.
  *
  * @param string $url An url
  * @return mixed Request body on success (string) otherwise false (boolean)
  */
 public function getUrlContent($url)
 {
     $config = (array) Configure::read('VatNumberCheck.socketConfig');
     $HttpSocket = new HttpSocket($config);
     try {
         $response = $HttpSocket->get($url);
         if ($response->isOk()) {
             return $response->body();
         }
     } catch (Exception $e) {
     }
     return false;
 }
コード例 #23
0
 /**
  * HTTP上で要求の送信
  * @param string $url
  * @param array $data
  * @param string $type
  */
 private function sendRequest($url, $data, $type = 'post')
 {
     $http = new HttpSocket();
     if ($type == 'post') {
         $response = $http->post($url, $data);
     } else {
         if ($type == 'get') {
             $response = $http->get($url, $data);
         } elseif ($type == 'delete') {
             $response = $http->delete($url, $data);
         }
     }
     return json_decode($response->body);
 }
コード例 #24
0
 protected function _fetchFromUrl($url)
 {
     $data = array('remote' => true);
     $data['name'] = end(explode('/', $url));
     $data['tmp_name'] = tempnam(sys_get_temp_dir(), $data['name']) . '.' . end(explode('.', $url));
     App::uses('HttpSocket', 'Network/Http');
     $httpSocket = new HttpSocket();
     $raw = $httpSocket->get($url);
     $response = $httpSocket->response;
     $data['size'] = strlen($raw);
     $data['type'] = reset(explode(';', $response['header']['Content-Type']));
     file_put_contents($data['tmp_name'], $raw);
     return $data;
 }
コード例 #25
0
ファイル: PlaceHelper.php プロジェクト: hoanvd/mobgame
 /**
  * Fetches data from lipsum.com and returns them as an array
  *
  * @param integer $amount amount of units to return
  * @param string $type single character, key of PlaceHelper::$_lipsumTypes
  * @param boolean $start decides if the generated string should start with words
  *   'Lorem ipsum dolor sit amet...'
  * @param boolean $noCache disables caching in runtime
  * @return array
  */
 protected function _fetchData($amount, $type, $start, &$noCache)
 {
     if (empty($this->_Socket)) {
         $this->_Socket = new HttpSocket();
     }
     $noCache = false;
     $url = $this->_textUrl($amount, $type, $start);
     try {
         $response = $this->_Socket->get($url);
         return $this->_decodeResponse($response, $noCache);
     } catch (SocketException $e) {
         $noCache = true;
         return array(__d('Sluggable', 'Connection to server lipsum.com failed. %s.', $e->getMessage()));
     }
 }
コード例 #26
0
ファイル: Post.php プロジェクト: sarvesh123/elastic-cake
 public function queryDoc($id)
 {
     $HttpSocket = new HttpSocket();
     try {
         $response = $HttpSocket->get(ES_BASE_URL . '/posts/' . $id . '?pretty');
     } catch (Exception $e) {
     }
     if (isset($response)) {
         $temp = json_decode($response->body, true);
         $arr['Post'] = $temp['_source'];
         return $arr;
     } else {
         return false;
     }
 }
コード例 #27
0
ファイル: correios.php プロジェクト: edubress/cake_ptbr
 function valorFrete(&$model, $servico, $cepOrigem, $cepDestino, $peso, $maoPropria = false, $valorDeclarado = 0.0, $avisoRecebimento = false)
 {
     // Validação dos parâmetros
     $tipos = array(CORREIOS_SEDEX, CORREIOS_SEDEX_A_COBRAR, CORREIOS_SEDEX_10, CORREIOS_SEDEX_HOJE, CORREIOS_ENCOMENDA_NORMAL);
     if (!in_array($servico, $tipos)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     $Validacao = new ValidacaoBehavior();
     if (!$Validacao->_cep($cepOrigem, '-') || !$Validacao->_cep($cepDestino, '-')) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if (!is_numeric($peso) || !is_numeric($valorDeclarado)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($peso > 30.0) {
         return ERRO_CORREIOS_EXCESSO_PESO;
     } elseif ($peso < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($valorDeclarado < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     // Ajustes nos parâmetros
     if ($maoPropria) {
         $maoPropria = 'S';
     } else {
         $maoPropria = 'N';
     }
     if ($avisoRecebimento) {
         $avisoRecebimento = 'S';
     } else {
         $avisoRecebimento = 'N';
     }
     // Requisição
     $HttpSocket = new HttpSocket();
     $uri = array('scheme' => 'http', 'host' => 'www.correios.com.br', 'port' => 80, 'path' => '/encomendas/precos/calculo.cfm', 'query' => array('resposta' => 'xml', 'servico' => $servico, 'cepOrigem' => $cepOrigem, 'cepDestino' => $cepDestino, 'peso' => $peso, 'MaoPropria' => $maoPropria, 'valorDeclarado' => $valorDeclarado, 'avisoRecebimento' => $avisoRecebimento));
     $retornoCorreios = trim($HttpSocket->get($uri));
     if ($HttpSocket->response['status']['code'] != 200) {
         return ERRO_CORREIOS_FALHA_COMUNICACAO;
     }
     $Xml = new Xml($retornoCorreios);
     $infoCorreios = $Xml->toArray();
     if (!isset($infoCorreios['CalculoPrecos']['DadosPostais'])) {
         return ERRO_CORREIOS_CONTEUDO_INVALIDO;
     }
     extract($infoCorreios['CalculoPrecos']['DadosPostais']);
     return array('ufOrigem' => $uf_origem, 'ufDestino' => $uf_destino, 'capitalOrigem' => $local_origem == 'Capital', 'capitalDestino' => $local_destino == 'Capital', 'valorMaoPropria' => $mao_propria, 'valorTarifaValorDeclarado' => $tarifa_valor_declarado, 'valorFrete' => $preco_postal - $tarifa_valor_declarado - $mao_propria, 'valorTotal' => $preco_postal);
 }
コード例 #28
0
 public function get($place)
 {
     $cacheKey = $this->_generateCacheKey('get', $place);
     if (($data = Cache::read($cacheKey)) === false) {
         $HttpSocket = new HttpSocket();
         $query = $this->_defaultQuery;
         $query['weather'] = $place;
         $results = $HttpSocket->get($this->_url, $query);
         if ($results->code != 200) {
             return false;
         }
         $data = $this->_decode($results->body);
         Cache::write($cacheKey, $data);
     }
     return $data;
 }
コード例 #29
0
 function delete($id = null)
 {
     if (!$id) {
         $this->Session->setFlash(__('Invalid id for getter', true));
         $this->redirect(array('action' => 'index'));
     }
     if ($this->Getter->delete($id)) {
         App::import('Core', 'HttpSocket');
         $HttpSocket = new HttpSocket();
         $HttpSocket->get("/timer/deleteInterval/{$id}");
         $this->Session->setFlash(__('Getter deleted', true));
         $this->redirect(array('action' => 'index'));
     }
     $this->Session->setFlash(__('Getter was not deleted', true));
     $this->redirect(array('action' => 'index'));
 }
コード例 #30
-1
ファイル: MhvController.php プロジェクト: hungnt88/5stars-1
 public function newbie_fetch($access_token, $server)
 {
     $this->autoLayout = false;
     $this->autoRender = false;
     if (isset($access_token) || isset($server)) {
         $HttpSocket = new HttpSocket(array('ssl_verify_peer' => false));
         $url = 'http://myhauvuong.5stars.vn/fanpage/newbie/' . $access_token . '/' . $server;
         $response = $HttpSocket->get($url);
         return $response->body;
     } else {
         return '{"error":"Thiếu dữ liệu"}';
     }
 }