本文整理汇总了PHP中HttpClient::setDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::setDebug方法的具体用法?PHP HttpClient::setDebug怎么用?PHP HttpClient::setDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::setDebug方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testJsonPost
function testJsonPost()
{
$http = new HttpClient('http://localhost/coredev_testserver/post_json.php');
$http->setContentType('application/json');
$http->setDebug(true);
$res = $http->post(array('str' => 'abc 123'));
$this->assertEquals($res, 'str=abc+123');
}
示例2: 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());
}
}
示例3: 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());
}
}
示例4: 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);
}
}
}
}
示例5: checkPass
/**
* Preferences are handled in _PassUser
*/
function checkPass($password)
{
$userid = $this->_userid;
if (!loadPhpExtension('openssl')) {
trigger_error(sprintf(_("The PECL %s extension cannot be loaded."), "openssl") . sprintf(_(" %s AUTH ignored."), 'Facebook'), E_USER_WARNING);
return $this->_tryNextUser();
}
$web = new HttpClient("www.facebook.com", 80);
if (DEBUG & _DEBUG_LOGIN) {
$web->setDebug(true);
}
// collect cookies from http://www.facebook.com/login.php
$web->persist_cookies = true;
$web->cookie_host = 'www.facebook.com';
$firstlogin = $web->get("/login.php");
if (!$firstlogin) {
if (DEBUG & (_DEBUG_LOGIN | _DEBUG_VERBOSE)) {
trigger_error(sprintf(_("Facebook connect failed with %d %s"), $web->status, $web->errormsg), E_USER_WARNING);
}
}
// Switch from http to https://login.facebook.com/login.php
$web->port = 443;
$web->host = 'login.facebook.com';
if (!($retval = $web->post("/login.php", array('user' => $userid, 'pass' => $password)))) {
if (DEBUG & (_DEBUG_LOGIN | _DEBUG_VERBOSE)) {
trigger_error(sprintf(_("Facebook login failed with %d %s"), $web->status, $web->errormsg), E_USER_WARNING);
}
}
$this->_authmethod = 'Facebook';
if (DEBUG & _DEBUG_LOGIN) {
trigger_error(get_class($this) . "::checkPass => {$retval}", E_USER_WARNING);
}
if ($retval) {
$this->_level = WIKIAUTH_USER;
} else {
$this->_level = WIKIAUTH_ANON;
}
return $this->_level;
}
示例6: 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;
}
示例7: load
/**
* Loads input data from RSS or Atom feeds into NewsItem entries
*/
function load($data)
{
if (is_array($data)) {
$this->addItems($data);
return;
}
if (is_url($data)) {
$http = new HttpClient($data);
if ($this->getDebug()) {
$http->setDebug();
}
$data = $http->getBody();
}
if (strpos($data, '<rss ') !== false) {
$feed = new RssReader();
} else {
if (strpos($data, '<feed ') !== false) {
$feed = new AtomReader();
} else {
echo 'NewsFeed->load error: unhandled feed: ' . substr($data, 0, 100) . ' ...' . ln();
return false;
}
}
if ($this->getDebug()) {
$feed->setDebug();
}
$feed->parse($data);
$this->title = $feed->getTitle();
$this->addItems($feed->getItems());
}
示例8: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
//AJXP_Logger::logAction("DL file", $httpVars);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
if (isset($httpVars["file"])) {
$parts = parse_url($httpVars["file"]);
$getPath = $parts["path"];
$basename = basename($getPath);
}
if (isset($httpVars["dlfile"])) {
$dlFile = $streamData["protocol"] . "://" . $repository->getId() . AJXP_Utils::decodeSecureMagic($httpVars["dlfile"]);
$realFile = file_get_contents($dlFile);
if (empty($realFile)) {
throw new Exception("cannot find file {$dlFile} for download");
}
$parts = parse_url($realFile);
$getPath = $parts["path"];
$basename = basename($getPath);
}
switch ($action) {
case "external_download":
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$unixProcess = AJXP_Controller::applyActionInBackground($repository->getId(), "external_download", $httpVars);
if ($unixProcess !== null) {
@file_put_contents($destStreamURL . "." . $basename . ".pid", $unixProcess->getPid());
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Triggering DL ", true, 2);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
require_once AJXP_BIN_FOLDER . "/class.HttpClient.php";
$mess = ConfService::getMessages();
session_write_close();
$client = new HttpClient($parts["host"]);
$collectHeaders = array("ajxp-last-redirection" => "", "content-disposition" => "", "content-length" => "");
$client->setHeadersOnly(true, $collectHeaders);
$client->setMaxRedirects(8);
$client->setDebug(false);
$client->get($getPath);
$pidHiddenFileName = $destStreamURL . "." . $basename . ".pid";
if (is_file($pidHiddenFileName)) {
$pid = file_get_contents($pidHiddenFileName);
@unlink($pidHiddenFileName);
}
AJXP_Logger::debug("COLLECTED HEADERS", $client->collectHeaders);
$collectHeaders = $client->collectHeaders;
$totalSize = -1;
if (!empty($collectHeaders["content-disposition"]) && strstr($collectHeaders["content-disposition"], "filename") !== false) {
$ar = explode("filename=", $collectHeaders["content-disposition"]);
$basename = trim(array_pop($ar));
$basename = str_replace("\"", "", $basename);
// Remove quotes
}
if (!empty($collectHeaders["content-length"])) {
$totalSize = intval($collectHeaders["content-length"]);
AJXP_Logger::debug("Should download {$totalSize} bytes!");
}
if ($totalSize != -1) {
$node = new AJXP_Node($destStreamURL . $basename);
AJXP_Controller::applyHook("node.before_create", array($node, $totalSize));
}
$qData = false;
if (!empty($collectHeaders["ajxp-last-redirection"])) {
$newParsed = parse_url($collectHeaders["ajxp-last-redirection"]);
$client->host = $newParsed["host"];
$getPath = $newParsed["path"];
if (isset($newParsed["query"])) {
$qData = parse_url($newParsed["query"]);
}
}
$tmpFilename = $destStreamURL . $basename . ".dlpart";
$hiddenFilename = $destStreamURL . "__" . $basename . ".ser";
$filename = $destStreamURL . $basename;
$dlData = array("sourceUrl" => $getPath, "totalSize" => $totalSize);
if (isset($pid)) {
$dlData["pid"] = $pid;
}
//file_put_contents($hiddenFilename, serialize($dlData));
$fpHid = fopen($hiddenFilename, "w");
fputs($fpHid, serialize($dlData));
fclose($fpHid);
$client->redirect_count = 0;
$client->setHeadersOnly(false);
$destStream = fopen($tmpFilename, "w");
if ($destStream !== false) {
$client->writeContentToStream($destStream);
$client->get($getPath, $qData);
fclose($destStream);
}
rename($tmpFilename, $filename);
unlink($hiddenFilename);
//.........这里部分代码省略.........
示例9: unset
/**
* Performs check of OpenID identity.
*
* This is the first step of OpenID authentication process.
* On success the function does not return (it does HTTP redirection to
* server and exits). On failure it returns false.
*
* @param bool $immediate enables or disables interaction with user
* @param string $id OpenID identity
* @param string $returnTo HTTP URL to redirect response from server to
* @param string $root HTTP URL to identify consumer on server
* @param mixed $extensions extension object or array of extensions objects
* @param Zend_Controller_Response_Abstract $response an optional response
* object to perform HTTP or HTML form redirection
* @return bool
*/
function _checkId($immediate, $id, $returnTo = null, $root = null, $extensions = null, $response = null)
{
$this->_setError('');
/*if (!Zend_OpenId::normalize($id)) {
$this->_setError("Normalisation failed");
return false;
}*/
$claimedId = $id;
if (!$this->_discovery($id, $server, $version)) {
$this->_setError("Discovery failed");
return false;
}
if (!$this->_associate($server, $version)) {
$this->_setError("Association failed");
return false;
}
if (!$this->_getAssociation($server, $handle, $macFunc, $secret, $expires)) {
/* Use dumb mode */
unset($handle);
unset($macFunc);
unset($secret);
unset($expires);
}
$params = array();
if ($version >= 2.0) {
//$params['openid.ns'] = Zend_OpenId::NS_2_0;
}
$params['openid.mode'] = $immediate ? 'checkid_immediate' : 'checkid_setup';
$params['openid.identity'] = $id;
$params['openid.claimed_id'] = $claimedId;
if ($version <= 2.0) {
global $request;
$session = $request->getSessionVar('openid');
$request->setSessionVar('identity', $id);
$request->setSessionVar('claimed_id', $claimedId);
}
if (isset($handle)) {
$params['openid.assoc_handle'] = $handle;
}
//$params['openid.return_to'] = Zend_OpenId::absoluteUrl($returnTo);
// See lib/WikiUser/FaceBook.php how to handle http requests
$web = new HttpClient("{$server}", 80);
if (DEBUG & _DEBUG_LOGIN) {
$web->setDebug(true);
}
if (empty($root)) {
//$root = Zend_OpenId::selfUrl();
if ($root[strlen($root) - 1] != '/') {
$root = dirname($root);
}
}
if ($version >= 2.0) {
$params['openid.realm'] = $root;
} else {
$params['openid.trust_root'] = $root;
}
/*if (!Zend_OpenId_Extension::forAll($extensions, 'prepareRequest', $params)) {
$this->_setError("Extension::prepareRequest failure");
return false;
}
*/
//Zend_OpenId::redirect($server, $params, $response);
return true;
}
示例10: array
<?php
include 'HttpClient.class.php';
//抓取页面的内容
$contents = HttpClient::quickGet('http://www.baidu.com/');
var_dump($contents);
//post请求某一个接口,返回的信息赋值给$res
$res = HttpClient::quickPost('http://example.com/sms.php', array('name' => 'kevin.liu', 'phone' => '18201042042'));
//可能有一些请求访问会出问题,则需要加一个userAgent
$client = new HttpClient('example.com');
$client->setDebug(true);
$client->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3a) Gecko/20021207');
if (!$client->get('/')) {
die('An error occurred: ' . $client->getError());
}
$contents = $client->getContent();
//还有一些情况是:在采集数据的时候必须先登陆,则可以先模拟登陆
$client = new HttpClient('example.com');
$client->post('/login.php', array('username' => 'kevin', 'password' => '123456'));
if (!$client->get('/private.php')) {
//采集数据的目标地址
die('An error occurred: ' . $client->getError());
}
$pageContents = $client->getContent();
示例11: postRequest
private function postRequest($url, $cookies, $protocol)
{
$httpClient = new HttpClient($this->hostName);
$httpClient->setDebug(true);
try {
$httpClient->setUserAgent("PaiPai API Invoker/PHP " . PHP_VERSION);
if (!$httpClient->post($url, $this->getParams())) {
return '<p>Request failed!</p>';
} else {
return $httpClient->getContent();
}
} catch (Exception $e) {
}
}