Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-28-2010, 01:14 PM XML-RPC Help
Average Talker

Posts: 24
Trades: 0
All,

Was needing to write to ISP and index into Joomla and WordPress for several sites. Originally opened thread:

http://www.phpfreaks.com/forums/inde...,313496.0.html

I found the XML-RPC code libraries and it seems to be the answer to my problem. I downloaded the 'IXR_Library.php' library from:

http://scripts.incutio.com/xmlrpc/

Installed and tweaked. Ran this sample test code:
PHP Code:
<?php
   
echo "Beginning the process! <br>";
   include (
'IXR_Library.php');
   
$url_lnk 'http://mysite.com/xmlrpc.php';
   
$uid_val 'myuser';
   
$pwd_val 'mypwd';
   
$title="XML-RPC Test Page - Test Draft Entry";
   
$body="Some test text.";
   
$catg="Uncategorized";
   
$client = new IXR_Client($url_lnk);
   if (!
$client->query('wp.getCategories',''$uid_val,$pwd_val)) {
      die (
'An error occurred - '.$client->getErrorCode().":".
             
$client->getErrorMessage());
   }
   
$res $client->getResponse();
   
$content = array('title'=>$title,
                  
'description'=>"$body<p>Hello World!</p>",
            
'mt_allow_comments'=>0,  // 1 to allow comments
            
'mt_allow_pings'=>0,  // 1 to allow trackbacks
            
'post_type'=>'page',
            
'post_parent'=>52,
            
'mt_keywords'=>$keywords,
            
'categories'=>$catg);
   if (!
$client->query('metaWeblog.newPost','',$uid_val,$pwd_val,$contentfalse)) {
      die(
'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
   }
   
$res $client->getResponse();    //with Wordpress, will report the ID of the new post
   
echo "Process Ended! <br>";
?>
which ran fine.

I then put this into my other code as a function of:
PHP Code:
   function put_wp_xml($parm_ray) {
      
// Called from line 1185
      
$url $parm_ray['L'];
      
$uid $parm_ray['U'];
      
$pwd $parm_ray['P'];
      
$bod $parm_ray['B'];
      include_once(
'IXR_Library.php');
      
$client = new IXR_Client($url);
      
$client->debug true;
      if (!
$client->query('wp.getCategories',''$uid,$pwd)) {
     die (
'An error occurred - '.$client->getErrorCode().":".
          
$client->getErrorMessage());
      }
      
$res $client->getResponse();
      
$cot = array ('title'=>$parm_ray['T'],
                 
'description'=>$parm_ray['B'],       // Content/Article
            
'mt_allow_comments'=>$parm_ray['M'], // 1 to allow comments
            
'mt_allow_pings'=>$parm_ray['G'],    // 1 to allow trackbacks
            
'post_type'=>$parm_ray['Y'],         // Type = Post or Page
            
'post_parent'=>$parm_ray['I'],       // Parent ID for subpage
            
'mt_keywords'=>$parm_ray['K'],       // Keyword Array
            
'categories'=>$parm_ray['C']);       // Category Array
      
if (!$client->query('metaWeblog.newPost','',$uid,$pwd,$cotfalse)) {
     die (
"An error occurred - ".$client->getErrorCode().
          
":".$client->getErrorMessage());
      }
      
$res $client->getResponse();    //with Wordpress, will report the ID of the new post
   
}        // end function 
and call it with:

PHP Code:
         foreach ($fls as $file) {        // loop through the files
            
$lines   file($file);
            
$fil_lns "";
            foreach (
$lines as $lval) {
               
//$fil_lns .= $lval."\n";
               
$fil_lns .= htmlspecialchars($lval);
            }  
// end foreach $lines
            
$row_val $row_lin[$n];
        
$url_sit $row_val['seo_site'];
        
$url_lnk $row_val['seo_thst'];
        
$uid_val $row_val['seo_tuid'];
        
$pwd_val $row_val['seo_tpwd'];
            if (
strpos($url_lnk,'abcarz')) { continue; }
        
$title   get_title($file);
        
$catg    "Uncategorized";
        
//$body="Some test text.";
            
$put_lin = array (L=>$url_lnk,U=>$uid_val,P=>$pwd_val,
                          
T=>$title,B=>$fil_lns,M=>0,G=>0,Y=>'page',
                              
I=>'',K=>'',C=>$catg);
        
$rc put_wp_xml($put_lin);
            
$x++;
            if (
$x==$lm) { break; }        // Break on file limit
         
}  // end foreach 
Originally I did not have the nested "foreach loop", so was only getting the filename transferred. When I added the nested foreach loop to get the file contents, I started getting this error:

Code:
An error occurred - -32700:parse error. not well formed
I've searched around for help on this error and as of now have nothing.

Hope someone can help with insite to this.

Thanks!

OMR
OldManRiver is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-29-2010, 11:01 PM Re: XML-RPC Help
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
I think[IMG]file:///C:/DOCUME%7E1/user/LOCALS%7E1/Temp/moz-screenshot.png[/IMG] the xml response is not well formed.

Try echo the response in a <pre> tag and find out the erring data.
Also, you should escape character data using CDATA.
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Reply     « Reply to XML-RPC Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38340 seconds with 12 queries