本文整理汇总了PHP中xmlrpc_decode1函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_decode1函数的具体用法?PHP xmlrpc_decode1怎么用?PHP xmlrpc_decode1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_decode1函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pingback
//.........这里部分代码省略.........
$port = isset($bits['port']) ? $bits['port'] : 80;
// Try to connect to the server at $host
$fp = fsockopen($host, $port, $errno, $errstr, 30);
if (!$fp) {
debug_fwrite($log, 'Couldn\'t open a connection to ' . $host . "\n\n");
continue;
}
// Send the GET request
$request = "GET {$path} HTTP/1.1\r\nHost: {$host}\r\nUser-Agent: WordPress/{$GLOBALS['wp_version']} PHP/" . phpversion() . "\r\n\r\n";
@ob_end_flush();
fputs($fp, $request);
// Start receiving headers and content
$contents = '';
$headers = '';
$gettingHeaders = true;
$found_pingback_server = 0;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if (trim($line) == '') {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
$contents .= trim($line) . "\n";
$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
} else {
$headers .= trim($line) . "\n";
$x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
}
if ($x_pingback_header_offset) {
preg_match('#x-pingback: (.+)#is', $headers, $matches);
$pingback_server_url = trim($matches[1]);
debug_fwrite($log, "Pingback server found from X-Pingback header @ {$pingback_server_url}\n");
$found_pingback_server = 1;
break;
}
if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
$quote = $pingback_link_offset_dquote ? '"' : '\'';
$pingback_link_offset = $quote == '"' ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
$pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
$pingback_href_start = $pingback_href_pos + 6;
$pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
$pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
debug_fwrite($log, "Pingback server found from Pingback <link /> tag @ {$pingback_server_url}\n");
$found_pingback_server = 1;
break;
}
}
if (!$found_pingback_server) {
debug_fwrite($log, "Pingback server not found\n\n*************************\n\n");
@fclose($fp);
} else {
debug_fwrite($log, "\n\nPingback server data\n");
// Assuming there's a "http://" bit, let's get rid of it
$host_clear = substr($pingback_server_url, 7);
// the trailing slash marks the end of the server name
$host_end = strpos($host_clear, '/');
// Another clear cut
$host_len = $host_end - $host_start;
$host = substr($host_clear, 0, $host_len);
debug_fwrite($log, 'host: ' . $host . "\n");
// If we got the server name right, the rest of the string is the server path
$path = substr($host_clear, $host_end);
debug_fwrite($log, 'path: ' . $path . "\n\n");
// Now, the RPC call
$method = 'pingback.ping';
debug_fwrite($log, 'Page Linked To: ' . $pagelinkedto . "\n");
debug_fwrite($log, 'Page Linked From: ');
$pagelinkedfrom = get_permalink($post_ID);
debug_fwrite($log, $pagelinkedfrom . "\n");
$client = new xmlrpc_client($path, $host, 80);
$message = new xmlrpcmsg($method, array(new xmlrpcval($pagelinkedfrom), new xmlrpcval($pagelinkedto)));
$result = $client->send($message);
if ($result) {
if (!$result->value()) {
debug_fwrite($log, $result->faultCode() . ' -- ' . $result->faultString());
} else {
$value = xmlrpc_decode1($result->value());
if (is_array($value)) {
$value_arr = '';
foreach ($value as $blah) {
$value_arr .= $blah . ' |||| ';
}
debug_fwrite($log, $value_arr);
} else {
debug_fwrite($log, $value);
}
}
}
@fclose($fp);
}
}
debug_fwrite($log, "\nEND: " . time() . "\n****************************\n\r");
debug_fclose($log);
for ($i = count($buf_keep) - 1; $i >= 0; $i--) {
ob_start();
echo $buf_keep[$i];
}
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:101,代码来源:functions.php
示例2: xmlrpc_decode1
function xmlrpc_decode1($xmlrpc_val)
{
$kind = $xmlrpc_val->kindOf();
if ($kind == "scalar") {
return $xmlrpc_val->scalarval();
} else {
if ($kind == "array") {
$size = $xmlrpc_val->arraysize();
$arr = array();
for ($i = 0; $i < $size; $i++) {
$arr[] = xmlrpc_decode1($xmlrpc_val->arraymem($i));
}
return $arr;
} else {
if ($kind == "struct") {
$xmlrpc_val->structreset();
$arr = array();
while (list($key, $value) = $xmlrpc_val->structeach()) {
$arr[$key] = xmlrpc_decode1($value);
}
return $arr;
}
}
}
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:25,代码来源:class-xmlrpc.php
示例3: mt_setPostCategories
function mt_setPostCategories($params)
{
global $xmlrpcusererr;
$xpostid = $params->getParam(0);
$xuser = $params->getParam(1);
$xpass = $params->getParam(2);
$xcats = $params->getParam(3);
$post_ID = $xpostid->scalarval();
$username = $xuser->scalarval();
$password = $xpass->scalarval();
$cats = xmlrpc_decode1($xcats);
foreach ($cats as $cat) {
$catids[] = $cat['categoryId'];
}
if (user_pass_ok($username, $password)) {
wp_set_post_cats('', $post_ID, $catids);
return new xmlrpcresp(new xmlrpcval($result, 'boolean'));
} else {
return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
}
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:21,代码来源:xmlrpc.php
示例4: blogger_setTemplate
function blogger_setTemplate($blogid, $username, $password, $template = "main", $string)
{
global $BLOGGER_APPID;
if (strpos($string, "<Blogger>") === false || strpos($string, "</Blogger>") === false) {
return "Invalid template, must contain <Blogger> and </Blogger> tags.";
exit;
}
// Connect to blogger server
if (!($blogClient = blogger_connectToBlogger())) {
return false;
exit;
}
// Create the variables that form the request
$XMLappid = new xmlrpcval($BLOGGER_APPID, "string");
$XMLblogid = new xmlrpcval($blogid, "string");
$XMLusername = new xmlrpcval($username, "string");
$XMLpassword = new xmlrpcval($password, "string");
$XMLtemplate = new xmlrpcval($template, "string");
$XMLstring = new xmlrpcval($string, "string");
// Construct the actual request message
$setTemplateRequest = new xmlrpcmsg("blogger.setTemplate", array($XMLappid, $XMLblogid, $XMLusername, $XMLpassword, $XMLstring, $XMLtemplate));
// Now send the request
$result_struct = $blogClient->send($setTemplateRequest);
// Check the results for an error
if (!$result_struct->faultCode()) {
// Get the results in a value-array
$values = $result_struct->value();
// Compile results into PHP array
$result_array = xmlrpc_decode1($values);
// Return something based on the check
if (!is_array($result_array)) {
$result_array = str_replace("<", "<", $result_array);
return $result_array;
} else {
return false;
}
} else {
return $result_struct->faultString();
}
}
开发者ID:honey93,项目名称:Real-Estate,代码行数:40,代码来源:blogger_.php
注:本文中的xmlrpc_decode1函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论