本文整理汇总了PHP中HttpClient::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getContent方法的具体用法?PHP HttpClient::getContent怎么用?PHP HttpClient::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: http_get_file
function http_get_file($url)
{
$httpClient = new HttpClient("epub.cnki.net");
$httpClient->get($url);
$content = $httpClient->getContent();
return $content;
}
示例2: core_call
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();
}
示例3: sendMessage
function sendMessage($msgInfo)
{
$clientt = new HttpClient(FEYIN_HOST, FEYIN_PORT);
if (!$clientt->post('/api/sendMsg', $msgInfo)) {
//提交失败
return 'faild';
} else {
return $clientt->getContent();
}
}
示例4: sendSms
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());
}
}
示例5: HttpClient
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;
}
示例6: crawlerProgramItems
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);
}
示例7: sendSms
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());
}
}
示例8: sendVerifyRemoteRequest
/**
* 获取校验结果
* @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);
}
示例9: HttpClient
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;
}
示例10: preLogUser
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);
}
}
}
}
示例11: createHttpClient
/**
* 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=" . $pass . "&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;
}
示例12: queryOrderNumbersByTime
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;
}
}
示例13: getRemoteConnexion
/**
* @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=" . $pass . "&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;
}
示例14: ajaxcheckandsaveAction
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);
}
示例15: queryPrinterStatus
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;
}
}