本文整理汇总了PHP中Http::body方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::body方法的具体用法?PHP Http::body怎么用?PHP Http::body使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::body方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publish
/**
* ハブサーバーに通知する
*/
public function publish()
{
if (empty($this->hubs) || empty($this->urls)) {
return;
}
$params = $this->params();
$http = new Http();
foreach ($this->hubs() as $hub) {
$http->raw(implode('&', $params));
$http->do_post($hub);
if ($http->status() != 204) {
throw new Exception(sprintf('[%d] %s', $http->status(), $http->body()));
}
}
}
示例2: 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");
}
示例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: 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");
}