2012-12-22 64 views
0

我使用下面的代碼通過XML-RPC發佈,它確實成功。但是當我發送一個長字符串$ bodypost時,我的帖子沒有正文內容。我測試它與HTML代碼,它的工作,然後我刪除所有空間,我的$ bodypost只有1行約4000字,它不工作。WordPress的XML-RPC發佈成功,但不適用於長身體

我該如何解決?

<?php 
function send_post($titlepost, $bodypost, $categorypost, $keywordspost) 
{ 
    require_once("IXR_Library.php.inc"); 
    $encoding='UTF-8'; 
    $client->debug = false; //Set it to false in Production Environment 
    $title= $titlepost; // $title variable will insert your blog title 
    $body= $bodypost; // $body will insert your blog content (article content) 
    $category=$categorypost; // Comma seperated pre existing categories. Ensure that these categories exists in your blog. 
    $keywords=$keywordspost; 
    $customfields=array('key'=>'Author-bio', 'value'=>'Autor Bio Here'); // Insert your custom values like this in Key, Value format 
     $title = htmlentities($title,ENT_NOQUOTES,$encoding); 
     $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding); 
     $content = array(
      'title'=>$title, 
      'description'=>$body, 
      'mt_allow_comments'=>0, // 1 to allow comments 
      'mt_allow_pings'=>0, // 1 to allow trackbacks 
      'post_type'=>'post', 
      'mt_keywords'=>$keywords, 
      'categories'=>array($category), 
      'custom_fields' => array($customfields) 


     ); 

    // Create the client object 
    $client = new IXR_Client('http://www.domain.com/xmlrpc.php'); 
    $username = "abc"; 
    $password = "abc"; 
    $params = array(0,$username,$password,$content,true); // Last parameter is 'true' which means post immideately, to save as draft set it as 'false' 
    // Run a query for PHP 
    if (!$client->query('metaWeblog.newPost', $params)) { 
     die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage()); 
    } 
    else 
     echo "Article Posted Successfully"; 
} 
?> 

回答

0

我發現如何解決它。如果我的身體代碼是由默認的Wordpress編輯器的源代碼提供的,但是如果我將其更改爲CkEditor,則此代碼不起作用!

相關問題