Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
*** скрытое содержание ***
function new_post($domain,$login,$pass,$title,$category,$content){
$client = new IXR_Client("http://".$domain.'/xmlrpc.php');
$content_struct['title'] = $title;
$content_struct['description'] = $content;
$content_struct['categories'] = array($category);
$response=$client->query("metaWeblog.newPost", '0', $login, $pass, $content_struct, '1');
if (!($response)){
Return False;
//die('xml - '.$client->xml.',Ошибка - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}else{
Return True;
}
}
function wp_xmlrpc_server() {
$this->methods = array(
// WordPress API
...
...
...
'wp.newCategory' => 'this:wp_newCategory',
...
...
...
function new_category($domain,$blog_id,$login,$pass,$category){
$client = new IXR_Client("http://".$domain.'/xmlrpc.php');
$content_struct['name'] = $category;
$response=$client->query("wp.newCategory", $blog_id, $login, $pass, $content_struct);
if (!($response)){
Return $client->message->message;
}else{
Return True;
}
}
function wp_newCategory($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$category = $args[3];
if(!$this->login_pass_ok($username, $password)) {
return($this->error);
}
do_action('xmlrpc_call', 'wp.newCategory');
// Set the user context and make sure they are
// allowed to add a category.
set_current_user(0, $username);
if(!current_user_can("manage_categories")) {
return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
}
// If no slug was provided make it empty so that
// WordPress will generate one.
if(empty($category["slug"])) {
$category["slug"] = "";
}
// If no parent_id was provided make it empty
// so that it will be a top level page (no parent).
if ( !isset($category["parent_id"]) )
$category["parent_id"] = "";
// If no description was provided make it empty.
if(empty($category["description"])) {
$category["description"] = "";
}
$new_category = array(
"cat_name" => $category["name"],
"category_nicename" => $category["slug"],
"category_parent" => $category["parent_id"],
"category_description" => $category["description"]
);
$cat_id = wp_insert_category($new_category);
if(!$cat_id) {
return(new IXR_Error(500, __("Sorry, the new category failed.")));
}
return($cat_id);
}
$cat = new_category("domen.ru","0","login","pass",$category);
faultCode 500 faultString Извините, новая рубрика не создана.
foreach($tags_Category as $val) {
if($val) {
$value = array("name" =>trim($val));
$x = new xmlrpcmsg("wp.newCategory",
array(php_xmlrpc_encode("1"),
php_xmlrpc_encode($login), // config.php
php_xmlrpc_encode($passwd),
php_xmlrpc_encode($value)));
$client->return_type = 'phpvals';
$r =$client->send($x);
if ($r->errno=="0"){
// echo "<p class=categories ><br><font color=green>Successfully Create Categories <b>".$val."</b></font><br><br></p>";
}else {
// echo "<p class=error ><br><font color=red>There are some error Create Categories <b>".$val."</b></font><br><br></p>";
}
}
}
C русским тоже работает, юзаем iconv();
на блогспот посмотри в блогофермеУ меня категории так получались
P.S. На блогспот как метки постить, кто подскажет?PHP:foreach($tags_Category as $val) { if($val) { $value = array("name" =>trim($val)); $x = new xmlrpcmsg("wp.newCategory", array(php_xmlrpc_encode("1"), php_xmlrpc_encode($login), // config.php php_xmlrpc_encode($passwd), php_xmlrpc_encode($value))); $client->return_type = 'phpvals'; $r =$client->send($x); if ($r->errno=="0"){ // echo "<p class=categories ><br><font color=green>Successfully Create Categories <b>".$val."</b></font><br><br></p>"; }else { // echo "<p class=error ><br><font color=red>There are some error Create Categories <b>".$val."</b></font><br><br></p>"; } } }