function http_get_file($url) { $httpClient = new HttpClient("epub.cnki.net"); $httpClient->get($url); $content = $httpClient->getContent(); return $content; }
public function core_call($serialized_request) { $client = new HttpClient($this->domain); $client->setCookies($this->cookies); $client->post($this->location . "json/", $serialized_request); return $client->getContent(); }
function sendMessage($msgInfo) { $clientt = new HttpClient(FEYIN_HOST, FEYIN_PORT); if (!$clientt->post('/api/sendMsg', $msgInfo)) { //提交失败 return 'faild'; } else { return $clientt->getContent(); } }
public static final function sendSms($path, $apikey, $encoded_text, $mobile, $tpl_id = '', $encoded_tpl_value = '') { $client = new HttpClient(self::HOST); $client->setDebug(false); if (!$client->post($path, array('apikey' => $apikey, 'text' => $encoded_text, 'mobile' => $mobile, 'tpl_id' => $tpl_id, 'tpl_value' => $encoded_tpl_value))) { return '-10000'; } else { return self::__replyResult($client->getContent()); } }
function _loadVersion() { require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'httpclient.class.php'; $client = new HttpClient('www.easy-joomla.org'); if (!$client->get('/components/com_versions/directinfo.php?catid=3')) { $this->setError($client->getError()); return false; } $this->_current = $client->getContent(); return true; }
static function crawlerProgramItems($date, $chnnel) { $url = replaceStr(CnTVLiveParse::BASE_EPISODE, '{DATE}', $date); $url = replaceStr($url, '{TV_CODE}', $chnnel); $client = new HttpClient('tv.cntv.cn'); $client->get('/epg'); $client->get($url); writetofile("program_live_item_crawler.log", "url:[http://tv.cntv.cn" . $url . "]"); $content = $client->getContent(); return CnTVLiveParse::parseMovieInfoByContent($content, $p_code, $type); }
public static final function sendSms($user, $password, $content, $mobiles) { $client = new HttpClient(self::HOST); $client->setDebug(false); date_default_timezone_set('PRC'); if (!$client->post('/sdk/send', array('accName' => $user, 'accPwd' => strtoupper($password), 'bizId' => date('YmdHis'), 'content' => mb_convert_encoding($content, 'UTF-8', 'UTF-8'), 'aimcodes' => $mobiles, 'dataType' => "xml"))) { return '-10000'; } else { return self::__replyResult($client->getContent()); } }
/** * 获取校验结果 * @param $ssid * @param $result * @param int $diff * @return type */ public static function sendVerifyRemoteRequest($ssid, $result, $diff = 0) { $client = new HttpClient(App::getConfig('YUC_SERVICE_NAME'), App::getConfig('YUC_SERVICE_PORT')); $client->setTimeout(App::getConfig('YUC_CLIENT_TIMEOUT')); //设置超时 $client->post(App::getConfig('YUC_VERIFY_PATH'), array('site_key' => App::getConfig('YUC_SITE_KEY'), 'ssid' => $ssid, 'result' => $result, 'diffsec_client' => $diff)); $post_req = json_decode($client->getContent(), TRUE); Log::Write('远程验证完成,输入结果为:' . $result . ',返回状态 :' . $client->getStatus() . ';' . 'POST 验证码正确性请求返回的数据:' . $client->getContent(), Log::DEBUG); if ($client->getStatus() == 200 && is_array($post_req)) { //200状态 正常返回数据 且返回数据格式正常 self::$_yuc_code = $post_req['code']; self::$_yuc_details = $post_req['details']; self::$_yuc_result = $post_req['result']; } else { self::$_yuc_code = 'E_SEVERVALID_001'; self::$_yuc_details = '服务器请求失败!'; self::$_yuc_result = 0; } return array('code' => self::$_yuc_code, 'result' => self::$_yuc_result, 'details' => self::$_yuc_details); }
function _getMatches($word_list) { $xml = ""; // Setup HTTP Client $client = new HttpClient('www.google.com'); $client->setUserAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR'); $client->setHandleRedirects(false); $client->setDebug(false); // Setup XML request $xml .= '<?xml version="1.0" encoding="utf-8" ?>'; $xml .= '<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">'; $xml .= '<text>' . htmlentities($word_list) . '</text></spellrequest>'; // Execute HTTP Post to Google if (!$client->post('/tbproxy/spell?lang=' . $this->lang, $xml)) { $this->errorMsg[] = 'An error occurred: ' . $client->getError(); return array(); } // Grab and parse content $xml = $client->getContent(); preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\\/c>/', $xml, $matches, PREG_SET_ORDER); return $matches; }
function preLogUser($sessionId) { require_once AJXP_BIN_FOLDER . "/class.HttpClient.php"; $client = new HttpClient($this->getOption("REMOTE_SERVER"), $this->getOption("REMOTE_PORT")); $client->setDebug(false); if ($this->getOption("REMOTE_USER") != "") { $client->setAuthorization($this->getOption("REMOTE_USER"), $this->getOption("REMOTE_PASSWORD")); } $client->setCookies(array($this->getOption("REMOTE_SESSION_NAME") ? $this->getOption("REMOTE_SESSION_NAME") : "PHPSESSID" => $sessionId)); $result = $client->get($this->getOption("REMOTE_URL"), array("session_id" => $sessionId)); if ($result) { $user = $client->getContent(); if ($this->autoCreateUser()) { AuthService::logUser($user, "", true); } else { // If not auto-create but the user exists, log him. if ($this->userExists($user)) { AuthService::logUser($user, "", true); } } } }
/** * Initialize and return the HttpClient * * @return HttpClient */ protected function createHttpClient() { require_once INSTALL_PATH . "/server/classes/class.HttpClient.php"; $httpClient = new HttpClient($this->host); $httpClient->cookie_host = $this->host; $httpClient->timeout = 50; AJXP_Logger::debug("Creating Http client", array()); //$httpClient->setDebug(true); if (!$this->use_auth) { return $httpClient; } $uri = ""; if ($this->auth_path != "") { $httpClient->setAuthorization($this->user, $this->password); $uri = $this->auth_path; } if (!isset($_SESSION["AJXP_REMOTE_SESSION"])) { if ($uri == "") { // Retrieve a seed! $httpClient->get($this->path . "?get_action=get_seed"); $seed = $httpClient->getContent(); $user = $this->user; $pass = $this->password; $pass = md5(md5($pass) . $seed); $uri = $this->path . "?get_action=login&userid=" . $user . "&password="******"&login_seed={$seed}"; } $httpClient->setHeadersOnly(true); $httpClient->get($uri); $httpClient->setHeadersOnly(false); $cookies = $httpClient->getCookies(); if (isset($cookies["AjaXplorer"])) { $_SESSION["AJXP_REMOTE_SESSION"] = $cookies["AjaXplorer"]; $remoteSessionId = $cookies["AjaXplorer"]; } } else { $remoteSessionId = $_SESSION["AJXP_REMOTE_SESSION"]; $httpClient->setCookies(array("AjaXplorer" => $remoteSessionId)); } AJXP_Logger::debug("Http Client created", array()); return $httpClient; }
public function queryOrderNumbersByTime($device_no, $date) { $msgInfo = array('clientCode' => $device_no, 'date' => $date); $client = new HttpClient(FEIE_HOST, FEIE_PORT); if (!$client->post('/FeieServer/queryorderinfo', $msgInfo)) { //提交失败 return 'faild'; } else { $result = $client->getContent(); return $result; } }
/** * @return HttpClient */ function getRemoteConnexion(&$remoteSessionId, $refreshSessId = false) { require_once INSTALL_PATH . "/server/classes/class.HttpClient.php"; $crtRep = ConfService::getRepository(); $httpClient = new HttpClient($crtRep->getOption("HOST")); $httpClient->cookie_host = $crtRep->getOption("HOST"); $httpClient->timeout = 10; //$httpClient->setDebug(true); if (!$crtRep->getOption("USE_AUTH")) { return $httpClient; } $uri = ""; if ($crtRep->getOption("AUTH_URI") != "") { $httpClient->setAuthorization($crtRep->getOption("AUTH_USER"), $crtRep->getOption("AUTH_PASS")); $uri = $crtRep->getOption("AUTH_URI"); } if (!isset($_SESSION["AJXP_REMOTE_SESSION"]) || $refreshSessId) { if ($uri == "") { // Retrieve a seed! $httpClient->get($crtRep->getOption("URI") . "?get_action=get_seed"); $seed = $httpClient->getContent(); $user = $crtRep->getOption("AUTH_USER"); $pass = $crtRep->getOption("AUTH_PASS"); $pass = md5(md5($pass) . $seed); $uri = $crtRep->getOption("URI") . "?get_action=login&userid=" . $user . "&password="******"&login_seed={$seed}"; } $httpClient->setHeadersOnly(true); $httpClient->get($uri); $httpClient->setHeadersOnly(false); $cookies = $httpClient->getCookies(); if (isset($cookies["AjaXplorer"])) { $_SESSION["AJXP_REMOTE_SESSION"] = $cookies["AjaXplorer"]; $remoteSessionId = $cookies["AjaXplorer"]; } } else { $remoteSessionId = $_SESSION["AJXP_REMOTE_SESSION"]; $httpClient->setCookies(array("AjaXplorer" => $remoteSessionId)); } return $httpClient; }
public function ajaxcheckandsaveAction() { $this->_helper->layout->disableLayout(); $code = urldecode($this->_request->getParam('code')); $config = Zend_Registry::get('config'); $writer_host = $config->writer->host; $uri = "/sns/find_sns.json"; //TODO: use config.ini $client = new HttpClient("localhost", "4000"); $access_token = NULL; $access_token_secret = NULL; $refresh_access_token = NULL; $expires_at = NULL; $expires_in = NULL; $username = NULL; $user = NULL; $nick = NULL; $profile_img_path = NULL; $big_profile_img_path = NULL; $small_profile_img_path = NULL; $client->get($uri, array('code' => $code)); if ($client->getStatus() == "200") { $rs = json_decode($client->getContent()); if (isset($rs->access_token_secret)) { $access_token_secret = $rs->access_token_secret; } if (isset($rs->refresh_access_token)) { $refresh_access_token = $rs->refresh_access_token; } if (isset($rs->expires_at)) { $expires_at = $rs->expires_at; } if (isset($rs->expires_in)) { $expires_in = $rs->expires_in; } if (isset($rs->username)) { $username = $rs->username; } if (isset($rs->user)) { $user = $rs->user; } if (isset($rs->nick)) { $nick = $rs->nick; } if (isset($rs->profile_img_path)) { $profile_img_path = $rs->profile_img_path; } if (isset($rs->big_profile_img_path)) { $big_profile_img_path = $rs->big_profile_img_path; } if (isset($rs->small_profile_img_path)) { $small_profile_img_path = $rs->small_profile_img_path; } $sns = new Sns(); $row = $sns->fetchRow($sns->select()->where('access_token = ?', $rs->access_token)); if (isset($row)) { $data = array('access_token' => $rs->access_token); $where = $sns->getAdapter()->quoteInto('id = ?', $row->id); $sns->update($data, $where); } else { try { $data = array('code' => $code, 'access_token' => $rs->access_token, 'access_token_secret' => $access_token_secret, 'refresh_access_token' => $refresh_access_token, 'expires_at' => $expires_at, 'expires_in' => $expires_in, 'consumer' => (int) $this->_currentUser->id, 'source' => $rs->source, 'timestamp' => date("Y-m-d H:i:s"), 'username' => $username, 'user' => $user, 'nick' => $nick, 'profile_img_path' => $profile_img_path, 'big_profile_img_path' => $big_profile_img_path, 'small_profile_img_path' => $small_profile_img_path); $sns->insert($data); $this->_helper->json(1); } catch (Exception $e) { print_r($e); } } $response = array("status" => 1); } else { $response = array("status" => 0); } $this->getHelper('json')->sendJson($response); }
public function queryPrinterStatus($device_no) { $client = new HttpClient(FEIE_HOST, FEIE_PORT); if (!$client->get('/FeieServer/queryprinterstatus?clientCode=' . $device_no)) { //请求失败 return 'faild'; } else { $result = $client->getContent(); return $result; } }
function getGopayServerTime() { $url = "https://mertest.gopay.com.cn/PGServer/time"; //如果方法报错,请修改参数为http://mertest.gopay.com.cn/PGServer/time $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; if (isset($bits['query'])) { $path .= '?' . $bits['query']; } $client = new HttpClient($host, $port); if (!$client->get($path)) { return false; } else { return $client->getContent(); } }
private static function send($url, $cookies, RequestSet $set, $cookieTable) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; $conn = new HttpClient($host, $port); $conn->setCookies($cookieTable); $conn->setContentType("text/xml;charset=UTF-8"); // Output ... $xml = $set->toXMLString(); if (!$conn->post($path, $xml)) { throw new Exception("PLLClient send exception"); } // Input ... $in_string = $conn->getContent(); $cookieTable = $conn->getCookies(); $resset = ResponseSet::parseXML($in_string); return $resset->getResponses(); }
/** * @return HttpClient */ public function getRemoteConnexion(&$remoteSecureToken, $refreshSessId = false, $repository = null) { require_once AJXP_BIN_FOLDER . "/class.HttpClient.php"; if ($repository != null) { $crtRep = $repository; } else { $crtRep = ConfService::getRepository(); } $httpClient = new HttpClient($crtRep->getOption("HOST")); $httpClient->cookie_host = $crtRep->getOption("HOST"); $httpClient->timeout = 10; if (isset($_SESSION["AJXP_REMOTE_SESSION"]) && is_array($_SESSION["AJXP_REMOTE_SESSION"])) { $httpClient->setCookies($_SESSION["AJXP_REMOTE_SESSION"]); } //$httpClient->setDebug(true); if (!isset($_SESSION["AJXP_REMOTE_SECURE_TOKEN"])) { $httpClient->get($crtRep->getOption("URI") . "?get_action=get_secure_token"); $remoteSecureToken = $httpClient->getContent(); $_SESSION["AJXP_REMOTE_SECURE_TOKEN"] = $remoteSecureToken; } else { $remoteSecureToken = $_SESSION["AJXP_REMOTE_SECURE_TOKEN"]; } if (!$crtRep->getOption("USE_AUTH")) { return $httpClient; } $uri = ""; if ($crtRep->getOption("AUTH_URI") != "") { $httpClient->setAuthorization($crtRep->getOption("AUTH_USER"), $crtRep->getOption("AUTH_PASS")); $uri = $crtRep->getOption("AUTH_URI") . "?secure_token={$remoteSecureToken}"; } if (!isset($_SESSION["AJXP_REMOTE_SESSION"]) || !is_array($_SESSION["AJXP_REMOTE_SESSION"]) || $refreshSessId) { if ($uri == "") { $this->logDebug("Remote_fs : relog necessary"); // Retrieve a seed! $httpClient->get($crtRep->getOption("URI") . "?get_action=get_seed&secure_token={$remoteSecureToken}"); $seed = $httpClient->getContent(); $cookies = $httpClient->getCookies(); if (isset($cookies["AjaXplorer"])) { $_SESSION["AJXP_REMOTE_SESSION"] = $cookies; } $user = $crtRep->getOption("AUTH_USER"); $pass = $crtRep->getOption("AUTH_PASS"); $pass = md5(md5($pass) . $seed); $uri = $crtRep->getOption("URI") . "?get_action=login&userid=" . $user . "&password="******"&login_seed={$seed}&secure_token={$remoteSecureToken}"; $httpClient->get($uri); $content = $httpClient->getContent(); $matches = array(); if (preg_match_all('#.*?secure_token="(.*?)".*?#s', $content, $matches)) { $remoteSecureToken = $matches[1][0]; $_SESSION["AJXP_REMOTE_SECURE_TOKEN"] = $remoteSecureToken; } $httpClient->setHeadersOnly(false); } else { $httpClient->setHeadersOnly(true); $httpClient->get($uri); $httpClient->setHeadersOnly(false); } $cookies = $httpClient->getCookies(); $_SESSION["AJXP_REMOTE_SESSION"] = $httpClient->getCookies(); } else { $httpClient->setCookies($_SESSION["AJXP_REMOTE_SESSION"]); } return $httpClient; }
function drupal_remote_auth($host, $uri, $login, $pass, $formId = "") { $client = new HttpClient($host); $client->setHandleRedirects(false); $res = $client->get($uri); $content = $client->getContent(); $xmlDoc = DOMDocument::loadHTML($content); $xPath = new DOMXPath($xmlDoc); if ($formId == "") { $formId = "user-login-form"; } $nodes = $xPath->query('//form[@id="' . $formId . '"]'); if (!$nodes->length) { return ""; } $form = $nodes->item(0); $postUri = $form->getAttribute("action"); $hiddens = $xPath->query('//input[@type="hidden"]', $form); AJXP_Logger::debug("Carry on Drupal hiddens " . $hiddens->length); $postData = array("name" => $login, "pass" => $pass, "Submit" => "Log in"); foreach ($hiddens as $hiddenNode) { $postData[$hiddenNode->getAttribute("name")] = $hiddenNode->getAttribute("value"); } $client->setHandleRedirects(false); $client->setHeadersOnly(true); $client->setCookies(extractResponseCookies($client)); $res2 = $client->post($postUri, $postData); $newCookies = extractResponseCookies($client); if (isset($newCookies["AjaXplorer"])) { return $newCookies["AjaXplorer"]; } return ""; }
/** * Workaround for allow_url_fopen, to get the content of an external URI. * It returns the contents in one slurp. Parsers might want to check for allow_url_fopen * and use fopen, fread chunkwise. (see lib/XmlParser.php) */ function url_get_contents($uri) { if (get_cfg_var('allow_url_fopen')) { // was ini_get('allow_url_fopen')) return @file_get_contents($uri); } else { require_once "lib/HttpClient.php"; $bits = parse_url($uri); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; if (isset($bits['query'])) { $path .= '?' . $bits['query']; } $client = new HttpClient($host, $port); $client->use_gzip = false; if (!$client->get($path)) { return false; } else { return $client->getContent(); } } }
function quickGet($url) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; if (isset($bits['query'])) { $path .= '?' . $bits['query']; } $client = new HttpClient($host, $port); if (!$client->get($path)) { return false; } else { return $client->getContent(); } }
public function printTxt($email_tpl, $dishCompany) { $str = "\n 微信平台订餐打印\n\t\n条目 单价(元) 数量\n----------------------------\n番茄炒粉 10.0 1\n客家咸香鸡 20.0 1\n\n备注:{$userInfo['des']}\n----------------------------\n合计:{$all_money}元 \n\n送货地址:{$userInfo['address']}\n联系电话:{$userInfo['tel']}\n订购时间:" . date("Y-m-d H:i:s"); $msgInfo = array('memberCode' => $dishCompany['memberCode'], 'msgDetail' => $email_tpl, 'deviceNo' => $dishCompany['deviceNo'], 'msgNo' => time() + 1, 'reqTime' => number_format(1000 * time(), 0, '', '')); $content = $msgInfo['memberCode'] . $msgInfo['msgDetail'] . $msgInfo['deviceNo'] . $msgInfo['msgNo'] . $msgInfo['reqTime'] . $dishCompany['feiyin_key']; $msgInfo['securityCode'] = md5($content); $msgInfo['mode'] = 2; $client = new HttpClient('my.feyin.net'); if ($client->post('/api/sendMsg', $msgInfo)) { $printstate = $client->getContent(); } if ($printstate == 0) { //echo '打印成功'; //$this->success('打印成功', U('Printer/index',array('token'=>$this->token))); } else { //echo '打印失败'; //$this->error('打印失败,错误代码:'.$printstate); } }
function main($subDir, $class, $cookieURL, $indexURL, $totalClass, $curClass, $code) { $isSleep = true; makeDir("./html/{$subDir}/{$class}/"); $dataFileName = "data/{$subDir}/{$class}.log"; $httpClient = new HttpClient("epub.cnki.net"); $content = ""; $indexFname = "./html/{$subDir}/{$class}/index.html"; $tf = iconv("utf-8", "gb2312", $indexFname); $cookies = ""; if (file_exists($tf)) { $isSleep = false; $content = file_get_contents($tf); echo "From cache get index.....\n"; } else { /*获取并设置cookie*/ $httpClient->get($cookieURL); $cookies = $httpClient->getCookies(); $httpClient->setCookies($cookies); if (!$cookies) { die("cookie error"); } $isSleep = true; $httpClient->get($indexURL); $content = $httpClient->getContent(); save($indexFname, $content); //保存 echo "save index file...\n"; } /* 解析出一共有多少页面 */ $pageCount = parsePageCount($content); echo "Page is {$pageCount} ****\n"; $articleCount = ARTICLE_PRE_PAGE * $pageCount; //计算一共有多少篇文章,大于等于实际文章数目,不影响结果 echo "total article is {$articleCount}\n"; $pageCount = $articleCount / ARTICLE_PRE_PAGE; $pageCount = ceil($pageCount); //向上取整,不放过任何数据 if ($pageCount == 0) { $pageCount = 1; } if ($pageCount > 50) { echo "page count is big than 50\n"; } echo "total page of {$class} is : {$pageCount}...............{$curClass} of {$totalClass}\n"; if ($isSleep) { fakeSleep(); } /* 抓取每一个页面并且保存下来,保存的同时进行解析 */ for ($i = 1; $i <= $pageCount; $i++) { $content = NULL; $pageI = getPageI($indexURL, $i); //第i页的地址 $htmlI = "./html/{$subDir}/{$class}/{$i}.html"; if (!file_exists(iconv("utf-8", "gb2312", $htmlI))) { $isSleep = true; $httpClient->setCookies($cookies); $httpClient->get($pageI); $content = $httpClient->getContent(); save($htmlI, $content); echo "From newwork & save {$i}.html..........[{$i} of {$pageCount}]\n"; } else { $tmpf2 = iconv("utf-8", "gb2312", $htmlI); $content = file_get_contents($tmpf2); $ok = validatePageContent($content); //是否出现了验证码 if (!$ok) { $i = $i - 1; delFile($htmlI); } else { $isSleep = false; echo "Find local file {$htmlI} & skip\n"; } //continue; } $logName = "./data/{$subDir}/{$class}.log"; if (!validatePageContent($content)) { $i = $i - 1; delFile($htmlI); dosleep(60); $httpClient = new HttpClient("epub.cnki.net"); $httpClient->get($cookieURL); $cookies = $httpClient->getCookies(); $httpClient->setCookies($cookies); continue; } parseContent($content, $logName, $code); if ($i != $pageCount && $isSleep) { fakeSleep(); } else { echo "+\n"; echo "+\n"; echo "+ {$class} done\n"; echo "+\n"; echo "+\n"; } } }
$sc = 30; echo "Cookie是空的,睡眠{$sc} S\n"; sleep($sc); } else { $httpClient->setCookies($cookies); } // $httpClient->get($cookieURL); // $cookies = $httpClient->getCookies(); } while (!$cookies); } $httpClient->setReferer($refUrl); $contentUrl = "http://epub.cnki.net" . $u; $contentSize = 0; do { $httpClient->get($contentUrl); $content = $httpClient->getContent(); //302页面 /*解析地址*/ $contentUrl = get_content_url($content); echo $contentUrl . "\n"; $saveContent = $paperName . "\t" . $contentUrl . "\n"; save($mapFile, $saveContent, "a+"); //echo "save $saveContent\n"; /*抓取论文摘要内容*/ $content = $httpClient->quickGet($contentUrl); $contentSize = strlen($content); if ($contentSize > 300) { save($cachedHtml, $content); } else { fakeSleep(); }
$nick = to_utf8($name); $setting = setting(); $block_list = is_array($setting->block_list) ? $setting->block_list : array(); $rooms = find_room(); $room_ids = array(); foreach ($rooms as $key => $value) { if (in_array($key, $block_list)) { $rooms[$key]['blocked'] = true; } else { array_push($room_ids, $key); } } $data = array('rooms' => join(',', $room_ids), 'buddies' => join(',', array_unique(array_merge($friend_ids, $buddy_ids, $stranger_ids))), 'domain' => $_IMC['domain'], 'apikey' => $_IMC['apikey'], 'endpoint' => $space['uid'], 'nick' => to_unicode($nick)); $client = new HttpClient($_IMC['imsvr'], $_IMC['impost']); $client->post('/presences/online', $data); $pageContents = $client->getContent(); //TODO: handle errors! $pageData = json_decode($pageContents); if ($client->status != "200" || empty($pageData->ticket)) { $ticket = ""; } else { $ticket = $pageData->ticket; } if (empty($ticket)) { //登录失败 echo '{status: "' . $client->status . '", "errorMsg":"' . $pageContents . '"}'; exit; } $buddy_online_ids = ids_array($pageData->buddies); //在线好友列表ids $clientnum = $pageData->clientnum;
function listException() { $now = number_format(1000 * time(), 0, '', ''); $client = new HttpClient(FEYIN_HOST, FEYIN_PORT); if (!$client->get('/api/listException?memberCode=' . MEMBER_CODE . '&reqTime=' . $now . '&securityCode=' . md5(MEMBER_CODE . $now . $this->feyin_key))) { //请求失败 return 'faild'; } else { return $client->getContent(); } }
public function onConnect(IWebSocketConnection $user) { if ($user->getAdminKey() == self::$ADMIN_KEY) { $this->say("[ECHO] Admin user connected"); return; } $h = $user->getHeaders(); $c = WebSocketFunctions::cookie_parse($h["Cookie"]); $client = new HttpClient($this->host); $client->cookies = $c; $client->get("/{$this->path}/?get_action=ws_authenticate&key=" . self::$ADMIN_KEY); $registry = $client->getContent(); //$this->say("[ECHO] Registry loaded".$registry); $xml = new DOMDocument(); $xml->loadXML($registry); $xPath = new DOMXPath($xml); $err = $xPath->query("//message[@type='ERROR']"); if ($err->length) { $this->say($err->item(0)->firstChild->nodeValue); $user->disconnect(); } else { $userRepositories = array(); $repos = $xPath->query("/tree/user/repositories/repo"); foreach ($repos as $repo) { $repoId = $repo->attributes->getNamedItem("id")->nodeValue; $userRepositories[] = $repoId; } $user->ajxpRepositories = $userRepositories; $user->ajxpId = $xPath->query("/tree/user/@id")->item(0)->nodeValue; if ($xPath->query("/tree/user/@groupPath")->length) { $groupPath = $xPath->query("/tree/user/@groupPath")->item(0)->nodeValue; if (!empty($groupPath)) { $user->ajxpGroupPath = $groupPath; } } } $this->say("[ECHO] User '" . $user->ajxpId . "' connected with " . count($user->ajxpRepositories) . " registered repositories "); }
$req['merId'] = $mer_id; // 商户代码 $req['orderTime'] = $orderTime; // 交易开始日期时间yyyyMMddHHmmss或yyyyMMdd $req['orderNumber'] = $orderNumber; // 订单号 // 保留域填充方法 $merReserved['test'] = "test"; $req['merReserved'] = UpmpService::buildReserved($merReserved); // 商户保留域(可选) $resp = array(); $validResp = UpmpService::query($req, $resp); // 商户的业务逻辑 if ($validResp) { // 服务器应答签名验证成功 include "./httpclient.php"; $resp = $resp; $client = new HttpClient('127.0.0.1'); // create a client $client->post('/' . CONST_APIDIR . '/third_api/upmp_feedback.php', $resp); // get $fp = $client->getContent(); echo $fp; exit; //exit; //print_r($resp); } else { // 服务器应答签名验证失败 echo $resp; exit; }
static function quickPost($url, $data) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; $client = new HttpClient($host, $port); if (!$client->post($path, $data)) { return false; } else { return $client->getContent(); } }
static function quickGet($url, $time = 30, $justhtml = true, $cks = array()) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; if (isset($bits['query'])) { $path .= '?' . $bits['query']; } $client = new HttpClient($host, $port); $client->oldurl = $url; $client->setCookies($cks); $client->timeout = $time; $client->justhtml = $justhtml; if (!$client->get($path)) { return false; } else { return $client->getContent(); } }