grandpa

any?
or what variable should send (post request) to xmlrpc.

php

 ?
is it ok to send request via curl?

thx

nop_90

go find the docs for blogger api.
that will tell u proper xml rpc calls to make.

go find docs on how to make xml rpc calls in

php

 .

grandpa

done, got the function from http://www.dentedreality.com.au/bloggerapi/

thx nop

nop_90

Applause Applause
I had in mind you would find the specs for posting to blog.
http://www.sixapart.com/developers/xmlrpc/
they give example how the "raw" call looks and also how to do xmlrpc call with

perl

 .

But that dented guy took the above and wrapped it nicely up for you Applause

grandpa

here is a simple function to post on wordpress.  Applause
that dented guy's function cant include a title while posting.

[code=

php

 ]
<?

php

 

//$url = full url to xmlrpc.

php

 , include http://

function wp_xmlrpc ($username, $password, $title, $body, $url){

$data = '<?xml version="1.0"?>
<methodCall>
<methodName>blogger.newPost</methodName>
<params>
<param>
<value><string></string></value>
</param>
<param>
<value><string></string></value>
</param>
<param>
<value><string>'.$username.'</string></value>
</param>
<param>
<value><string>'.$password.'</string></value>
</param>
<param>
<value><code>&lt;title&gt;'.$title.'&lt;/title&gt;</code>
<string>'.$body.'</string></value>
</param>
<param>
<value><boolean>1</boolean></value>
</param>
</params>
</methodCall>';

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
$result = curl_exec($curl);
curl_close($curl);

return $result;
}

?>

nop_90

he is using the older blogger api.
the metaWeblog api like enhances the older api
(not sure what the correct terminology is).

if the blog supports if (WP does) to have title in post etc use this call
http://www.sixapart.com/developers/xmlrpc/metaweblog_api/metaweblognewpost.html

itchy

messed around with this for a few hours and this updated code now posts titles with posts (thanx nop for the bone):

function wp_xmlrpc ($username, $password, $title, $post, $url){
    $data = '<?xml version="1.0" encoding="UTF-8"?>
    <methodCall>
    <methodName>metaWeblog.newPost</methodName>
    <params>
    <param><value><string></string></value></param>
    <param><value><string>'.$username.'</string></value></param>
    <param><value><string>'.$password.'</string></value></param>
    <param><value>
    <struct>
    <member><name>title</name><value><string>'.$title.'</string></value></member>
    <member><name>description</name><value><string>'.$post.'</string></value></member>
    </struct>
    </value></param>
    <param><value><boolean>true</boolean></value></param>
    </params>
    </methodCall>';
    // data set make the post
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
wp_xmlrpc($username, $password, $title, $post, $url);

itchy

sorry [req] anyone have any code/tips on updating blogroll links on ****.wordpress.com as i'm having a really hard time jumping through all the js loops they have put up since the site rebuild?
thanx itchy

breeze

Thanks for the class guys, been breaking my head before but this works great.
Any idea of how to include a categoy and to set post status to draft?

I thought this would work but doesn't:

<name>post_status</name><value><string>draft</string></value>


Perkiset's Place Home   Politics @ Perkiset's