本文整理汇总了PHP中vB_XML_Parser::parse_xml方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_XML_Parser::parse_xml方法的具体用法?PHP vB_XML_Parser::parse_xml怎么用?PHP vB_XML_Parser::parse_xml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_XML_Parser
的用法示例。
在下文中一共展示了vB_XML_Parser::parse_xml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_ping_notification
/**
* Send a pingback / trackback request
*
* @param array Bloginfo
* @param string Destination URL
* @param string Title of the blog
*
* @return mixed error string on failure, true on success or apparent success
*/
function send_ping_notification(&$bloginfo, $desturl, $blogtitle)
{
global $vbulletin;
if (!intval($bloginfo['blogid']))
{
return false;
}
$ourblogurl = $vbulletin->options['bburl'] . '/blog.php?blogid=' . $bloginfo['blogid'];
$pingback_dest = '';
$trackback_dest = $desturl;
require_once(DIR . '/includes/functions_file.php');
if ($headresult = fetch_head_request($desturl))
{
if (!empty($headresult['x-pingback']))
{
$pingback_dest = $headresult['x-pingback'];
}
else if ($headresult['http-response']['statuscode'] == 200 AND preg_match('#text\/html#si', $headresult['content-type']))
{
// Limit to 5KB
// Consider adding the ability to Kill the transfer on </head>\s+*<body to class_vurl.php
if ($bodyresult = fetch_body_request($desturl, 5120))
{
// search head for <link rel="pingback" href="pingback server">
if (preg_match('<link rel="pingback" href="([^"]+)" ?/?>', $bodyresult, $matches))
{
$pingback_dest = $matches[0];
}
else if (preg_match('#<rdf:Description((?!<\/rdf:RDF>).)*dc:identifier="' . preg_quote($desturl, '#') . '".*<\/rdf:RDF>#siU', $bodyresult))
{
if (preg_match('#<rdf:Description(?:(?!<\/rdf:RDF>).)*trackback:ping="([^"]+)".*<\/rdf:RDF>#siU', $bodyresult, $matches))
{
$trackback_dest = trim($matches[1]);
}
}
}
}
if (!empty($pingback_dest))
{
// Client
require_once(DIR . '/includes/class_xmlrpc.php');
$xmlrpc = new vB_XMLRPC_Client($vbulletin);
$xmlrpc->build_xml_call('pingback.ping', $ourblogurl, $desturl);
if ($pingresult = $xmlrpc->send_xml_call($pingback_dest))
{
require_once(DIR . '/includes/class_xmlrpc.php');
$xmlrpc_server = new vB_XMLRPC_Server($vbulletin);
$xmlrpc_server->parse_xml($pingresult['body']);
$xmlrpc_server->parse_xmlrpc();
}
// NOT FINSIHED
write_trackback_log('pingback', 'out', 0, $pingresult, $bloginfo, $desturl);
// Not always a success but we can't know for sure
return true;
}
else
{
// Client
require_once(DIR . '/includes/class_trackback.php');
$tb = new vB_Trackback_Client($vbulletin);
$excerpt = fetch_censored_text(fetch_trimmed_title(strip_bbcode(strip_quotes($bloginfo['pagetext']), false, true), 255));
if ($result = $tb->send_ping($trackback_dest, $ourblogurl, $bloginfo['title'], $excerpt, $blogtitle))
{
require_once(DIR . '/includes/class_xml.php');
$xml_object = new vB_XML_Parser($result['body']);
$xml_object->include_first_tag = true;
if ($xml_object->parse_xml() AND $xml_object->parseddata['response']['error'] === '0')
{
write_trackback_log('trackback', 'out', 0, $result, $bloginfo, $desturl);
return true;
}
}
write_trackback_log('trackback', 'out', 3, $result, $bloginfo, $desturl);
// Not always a success but we can't know for sure
return true;
}
}
write_trackback_log('none', 'out', 1, '', $bloginfo, $desturl);
return false;
}