本文整理汇总了PHP中HTTP_Request2::setURL方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request2::setURL方法的具体用法?PHP HTTP_Request2::setURL怎么用?PHP HTTP_Request2::setURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP_Request2
的用法示例。
在下文中一共展示了HTTP_Request2::setURL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_request
/**
* GET Request
*
* @param $url
* @param $datas
* @return string
*/
public function get_request($url, $datas = array())
{
$body = '';
try {
$url2 = new Net_URL2($url);
foreach ($datas as $key => $val) {
$url2->setQueryVariable($key, mb_convert_encoding($val, $this->response_encoding, 'UTF-8'), true);
}
$this->http->setURL($url2);
$this->http->setMethod(HTTP_Request2::METHOD_GET);
if (!empty($this->cookies)) {
foreach ($this->cookies as $cookie) {
$this->http->addCookie($cookie['name'], $cookie['value']);
}
}
$response = $this->http->send();
if (count($response->getCookies())) {
$this->cookies = $response->getCookies();
}
$body = mb_convert_encoding($response->getBody(), 'UTF-8', $this->response_encoding);
} catch (Exception $e) {
debug($e->getMessage());
}
return $body;
}
示例2: retrive
function retrive()
{
$req = new HTTP_Request2("");
$req->setURL($this->api_url);
$res = $req->send();
$resbody = $res->getBody();
if ($resbody) {
$xml = $resbody;
} else {
return 0;
}
if ($xml) {
$fp = fopen($this->file_path, "w");
fputs($fp, $xml);
fclose($fp);
return 1;
} else {
return 0;
}
}
示例3: readFolder
function readFolder($folder)
{
global $vfs, $basepath, $dbh, $update, $host;
static $level;
$level++;
if (substr($folder, -5) == '/.svn') {
return;
}
checkDocLog('readFolder ' . $folder);
$result = $vfs->listFolder($folder);
if ($folder == '.') {
$folder = '';
}
foreach ($result as $file) {
if (is_dir($basepath . $folder . '/' . $file['name'])) {
if ($folder == '') {
$newfolder = $file['name'];
} else {
$newfolder = $folder . '/' . $file['name'];
}
readFolder($newfolder);
$level--;
} else {
if ($level == 2 && preg_match("/\\.xml\$/", $file['name'])) {
$path = $basepath . $folder . '/' . $file['name'];
try {
list($title, $package) = checkDocumentation($path);
$url = '/manual/en/' . $package . '.php';
checkDocLog('trying ' . $host . $url);
$request = new HTTP_Request2($host . $url);
$response = $request->send();
if ($response->getStatus() >= 400) {
$new_url = preg_replace("=\\.([^\\.]+)\\.php\$=", ".php", $url);
$request->setURL($host . $new_url);
checkDocLog('trying2 ' . $host . $new_url);
$response = $request->send();
$url = $response->getStatus() > 400 ? '' : $new_url;
}
if ($url) {
checkDocLog('Found doc url: ' . $url . ', title: ' . $title);
$res = $dbh->execute($update, array($url, $title));
} else {
checkDocLog('No url for ' . $title);
}
} catch (Exception $e) {
print $e->getMessage() . "\n";
}
}
}
}
}
示例4: get
/**
* Required to request the root i-name (XRI) XRD which will provide an
* error message that the i-name does not exist, or else return a valid
* XRD document containing the i-name's Canonical ID.
*
* @param string $url URI
* @param string $serviceType Optional service type
*
* @return HTTP_Request
* @todo Finish this a bit better using the QXRI rules.
*/
protected function get($url, $serviceType = null)
{
$request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $this->getHttpRequestOptions());
$netURL = new Net_URL2($url);
$request->setHeader('Accept', 'application/xrds+xml');
if ($serviceType) {
$netURL->setQueryVariable('_xrd_r', 'application/xrds+xml');
$netURL->setQueryVariable('_xrd_t', $serviceType);
} else {
$netURL->setQueryVariable('_xrd_r', 'application/xrds+xml;sep=false');
}
$request->setURL($netURL->getURL());
try {
return $request->send();
} catch (HTTP_Request2_Exception $e) {
throw new Services_Yadis_Exception('Invalid response to Yadis protocol received: ' . $e->getMessage(), $e->getCode());
}
}
示例5: createClient
/**
*
* @param type $method
* @param string $url
* @return \HTTP_Request2
*/
protected function createClient($method = 'GET', $urlPart = null)
{
$url = $this->url . $this->requestPath;
if ($urlPart) {
$url .= '/' . $urlPart;
}
$request = new HTTP_Request2();
$request->setMethod($method);
$request->setURL($url);
$request->setConfig(array('ssl_verify_peer' => false));
return $request;
}
示例6: array
$project_link->addFilter("htmlspecialchars");
$project_link->addRule('required', "Please enter your project link");
$is_active = $form->addElement("checkbox", 'is_active', array('checked' => $channel["is_active"] ? 'checked' : ''));
$is_active->setLabel("Active?");
$form->addElement("submit");
if ($form->validate()) {
$url = new Net_URL2($project_name->getValue());
try {
$req = new HTTP_Request2();
$dir = explode("/", $url->getPath());
if (!empty($dir)) {
array_pop($dir);
}
$dir[] = 'channel.xml';
$url->setPath(implode("/", $dir));
$req->setURL($url->getURL());
channel::validate($req, $chan);
channel::edit($channel['name'], $project_label->getValue(), $project_link->getValue(), $contact_name->getValue(), $contact_email->getValue());
if ($is_active->getValue()) {
channel::activate($channel['name']);
} else {
channel::deactivate($channel['name']);
}
echo "<div class=\"success\">Changes saved</div>\n";
} catch (Exception $exception) {
echo '<div class="errors">';
switch ($exception->getMessage()) {
case "Invalid channel site":
case "Empty channel.xml":
echo "The submitted URL does not ";
echo "appear to point to a valid channel site. You will ";