本文整理汇总了PHP中HTTPClient::SetTimeouts方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTPClient::SetTimeouts方法的具体用法?PHP HTTPClient::SetTimeouts怎么用?PHP HTTPClient::SetTimeouts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPClient
的用法示例。
在下文中一共展示了HTTPClient::SetTimeouts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HTTPClient
function testData_XML_RSS_RSSReader()
{
$http = new HTTPClient();
// rss 2.0
$url = 'http://aggressiva.livejournal.com/data/rss';
$http->SetTimeouts(30, 15);
$xml = $http->Fetch($url);
$Reader = new RSSReader();
$Reader->Parse($xml);
$data = $Reader->GetData();
$this->assertTrue($data['channel'], "No channel found");
$this->assertTrue($data['item']['pubdate'], "No items found");
}
示例2: GetBlogEntries
/**
* Get blog entries from myspace account
*
* @var int friend account number (if not default)
*/
function GetBlogEntries($accountid = 0)
{
if (!$accountid) $accountid = $this->AccountID;
$blog_page = sprintf(self::BLOG_ATOM_URL, $accountid);
$http = new HTTPClient();
$http->SetTimeouts(60, 30);
$http->Fetch($blog_page);
$blog_xml = $http->Result;
$Reader = new RSSReader();
$Reader->Parse($blog_xml);
$data = $Reader->GetData();
if (!$data)
return false;
$blogs = array();
foreach($data['item']['title'] as $key => $subject)
{
$timestamp = strtotime($data['item']['published'][$key]);
array_push($blogs, array(
'date' => date("Y-m-d", $timestamp),
'subject' => $subject,
'category' => "",
'content' => $data['item']['content'][$key],
'time' => date("H:i", $timestamp),
'comments' => "",
'timestamp' => $timestamp
));
}
return $blogs;
}
示例3: GetBlogEntries
/**
* Get blog entries from myspace account
*
* @var int friend account number (if not default)
*/
function GetBlogEntries($accountid)
{
if (!$accountid) $accountid = $this->AccountID;
$blog_page = sprintf(self::BLOG_URL, $accountid);
$http = new HTTPClient();
$http->SetTimeouts(60, 30);
$http->Fetch($blog_page);
if (preg_match("/<title>[^<]*302 Found[^<]*<\/title>/msi", $http->Result))
{
$blog_page = sprintf(self::BLOG_URL_SIMPLE, $accountid);
$http = new HTTPClient();
$http->SetTimeouts(60, 30);
$http->Fetch($blog_page);
}
$blog_xml = $http->Result;
$Reader = new RSSReader();
$Reader->Parse($blog_xml);
$data = $Reader->GetData();
if (!$data)
return false;
$blogs = array();
foreach((array)$data['item']['title'] as $key => $subject)
{
$timestamp = strtotime($data['item']['pubdate'][$key]);
array_push($blogs, array(
'date' => date("Y-m-d", $timestamp),
'subject' => $subject,
'category' => "",
'content' => $data['item']['description'][$key],
'time' => date("H:i", $timestamp),
'comments' => "",
'timestamp' => $timestamp
));
}
return $blogs;
}