2012-12-22 2 views
0

XML-RPC를 통해 게시하려면 아래 코드를 사용하십시오. 성공합니다. 그러나 긴 문자열 $ bodypost를 보내면 내 게시물에 본문 내용이 없습니다. 나는 html 코드로 테스트했다. 작동하고있다. 그런 다음 모든 공간을 제거한다. $ bodypost는 약 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로 변경하면 작동합니다!

관련 문제