本文整理汇总了PHP中Http::do_get方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::do_get方法的具体用法?PHP Http::do_get怎么用?PHP Http::do_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::do_get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
public function download($save_dir, $save_filename, $ext = true)
{
$b = new Http();
$b->do_get($this->url() . "&fmt=22");
if (preg_match("/var[\\s]+swfArgs[\\s]*=[\\s]*(\\{.+?\\})/m", $b->body(), $match)) {
$json = Text::parse_json($match[1]);
$base_url = "http://www.youtube.com/get_video?video_id=" . $json["video_id"] . "&t=" . $json["t"];
$url = $base_url . "&fmt=22";
if ($b->do_head($url)->status() !== 200) {
$url = $base_url . "&fmt=18";
}
$b->do_download($url, File::absolute($save_dir, $save_filename) . ($ext ? $this->ext : ""));
return;
}
throw new Exception("undef video");
}
示例2: lookup
/**
* 短縮urlから復元する
* @param $url
* @return string
*/
public static function lookup($url)
{
if (strpos($url, "http://tinyurl.com/") !== 0) {
$url = "http://tinyurl.com/" . $url;
}
$http = new Http();
$http->status_redirect(false);
$http->do_get($url);
if ($http->status() === 301 && preg_match("/Location:[ ](.*)/i", $http->head(), $redirect_url)) {
return trim($redirect_url[1]);
}
return $url;
/***
eq("http://rhaco.org",Tinyurl::lookup("http://tinyurl.com/6bkavu"));
eq("http://rhaco.org",Tinyurl::lookup("6bkavu"));
*/
}
示例3: download
public function download($save_dir, $save_filename, $ext = true)
{
$b = new Http();
if (!empty($this->original_image_url)) {
$b->do_download($this->original_image_url, File::absolute($save_dir, $save_filename) . ($ext ? ".jpg" : ""));
return;
} else {
$b->do_get($this->url);
if (Tag::setof($tag, $b->body(), "body")) {
foreach ($tag->in("script") as $s) {
if (preg_match("/addVariable\\('url', '(.+?)'\\)/", $s->value(), $match)) {
$b->do_download(trim($match[1]), File::absolute($save_dir, $save_filename) . ($ext ? ".flv" : ""));
return;
}
}
}
}
throw new Exception("undef video");
}
示例4: __setup_rep__
/**
* Repositoryが提供するアプリケーションとライブラリの一覧を表示する
* -rep rhaco.org
*/
public static function __setup_rep__(Request $req, $value)
{
$http = new Http();
$q = $req->in_vars("q");
foreach (array("lib" => "Libraries:", "app" => "\nApplications:") as $type => $label) {
if (Tag::setof($tag, $http->do_get(Repository::xml_url($type, $value)), "repository")) {
$list = array();
$max_length = 0;
foreach ($tag->in("package") as $p) {
if (empty($q) || Text::imatch($p->in_param("name") . " " . $p->in_param("path") . " " . $p->in_param("summary") . " " . $p->value(), $q)) {
$list[] = $p;
if ($max_length < strlen($p->in_param("path"))) {
$max_length = strlen($p->in_param("path"));
}
}
}
if (!empty($list)) {
self::info_print($label);
foreach ($list as $p) {
self::println(" " . str_pad($p->in_param("path"), $max_length) . " " . $p->in_param("summary"));
}
}
}
}
}
示例5: server_address
private static function server_address($url)
{
$server = $url;
if (strpos($server, "://") === false) {
$server = isset(self::$server_alias[$server]) ? self::$server_alias[$server] : "http://" . $server;
}
if (substr($server, -1) == "/") {
$server = substr($server, 0, -1);
}
try {
$http = new Http();
if ($http->do_get($server . "/__repository__.php/check")->status() === 200 && $http->body() == "") {
return $server;
}
if ($http->do_get($server . "/__repository__.xml")->status() === 200) {
if (Tag::setof($tag, $http->body(), "map")) {
foreach ($tag->in("repository") as $rep) {
try {
if (!$rep->is_param("domain")) {
return self::server_address($rep->in_param("url"));
}
} catch (InvalidArgumentException $e) {
}
}
}
}
} catch (InvalidArgumentException $e) {
}
throw new InvalidArgumentException("server `" . $url . "` not found");
}