The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 09:12:33 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: [req] xmlrpc wp posting function/class  (Read 5706 times)
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« on: May 24, 2007, 07:26:29 AM »

any?
or what variable should send (post request) to xmlrpc.php?
is it ok to send request via curl?

thx
Logged
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #1 on: May 24, 2007, 08:23:23 PM »

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.
Logged
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #2 on: May 25, 2007, 12:05:03 PM »

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

thx nop
Logged
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #3 on: May 25, 2007, 05:34:01 PM »

 ROFLMAO ROFLMAO
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 Smiley
Logged
grandpa
Rookie
**
Offline Offline

Posts: 20



View Profile
« Reply #4 on: May 25, 2007, 09:44:11 PM »

here is a simple function to post on wordpress.  Smiley
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;
}

?>
« Last Edit: May 25, 2007, 09:48:55 PM by grandpa » Logged
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #5 on: May 25, 2007, 09:53:10 PM »

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
Logged
itchy
Rookie
**
Offline Offline

Posts: 12



View Profile
« Reply #6 on: June 10, 2007, 11:13:25 AM »

messed around with this for a few hours and this updated code now posts titles with posts (thanx nop for the bone):
Code:
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);
Logged

No links in signatures please
itchy
Rookie
**
Offline Offline

Posts: 12



View Profile
« Reply #7 on: June 12, 2007, 01:07:54 AM »

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
Logged

No links in signatures please
breeze
n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #8 on: October 15, 2007, 10:31:35 AM »

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>
Logged

No links in signatures please
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!