On 08/12/2008, at 3:43 PM, Sonia Hamilton wrote:
I found the docs a bit confusing, but I've tested it using curl.  eg
for POSTing a new article (something very roughly like this):

curl -H "Authorization: GoogleLogin auth=$Auth" \
   -H "Content-Type: application/atom+xml" \
   -d "@example_post.xml" \
   https://www.blogger.com/feeds/$blog_id/posts/default

Anyone know how to do the same for wordpress?


I used this recently. It worked for me, probably won't work for you ;)
The blog post has the subject as the first line, and the body in the rest.
For me, every paragraph was one long line, and a blank line between
paragraphs, I'm not sure how formating will look if you press enter at
the end of every line.

call it whatever and run it with the filename as the first argument.
./whatever <filename>

The address, username and password are hard coded in the python program.

#!/usr/bin/python

import xmlrpclib
from pprint import pprint
from datetime import datetime
from sys import argv
from string import rstrip

def blogPost( server, username, password, date, title, content ):
   datastruct = {'pubDate': date, 'description':content, 'title':title}
returncode = server.metaWeblog.newPost('1',username,password,datastruct,1)
   print returncode

servname = xmlrpclib.Server("http://blog.com/xmlrpc.php";)

d_username = 'admin'
d_password = 'password'

n_date = datetime.isoformat(datetime.now(), ' ')

try:
   f = open(argv[1])
except:
   print("error opening file")
   exit()

n_title = rstrip(f.readline())
content = f.readlines()
n_content = str()

for line in content:
   n_content = n_content + line.rstrip() + "\n"

n_content = n_content.decode('ascii', "replace")
print(blogPost(servname, d_username, d_password, n_date, n_title, n_content))


--

http://chesterton.id.au/blog/
http://barrang.com.au/


--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to