Rohmad Hidayat's Blog

Icon

My Notes on Mobile Technology, Python GUI, Python Web Framework, Software Development, Database, Server, Embedded System, Mini Computer

Kode Python CE sederhana untuk posting wordpress via Windows Mobile

import xmlrpclib

def getfile(filename):
filehandle = open(filename, “r”)
filecontents = filehandle.read()
#textview.delete(“1.0”, “end”)
#textview.insert(“end”, filecontents)
filehandle.close()
return filecontents

def openfile():
import tkFileDialog

filename = tkFileDialog.askopenfilename()

return filename

user = ‘user’
passwd = ‘passwd’
server = xmlrpclib.ServerProxy(‘https://rhdblog.wordpress.com/xmlrpc.php’)

blog_id = 0
#title = ‘Test Posting From Python LAgi’
title=raw_input(‘Judul Posting’)
#content = ‘test content, from python…tessssssss lagiii’
#content=raw_input(‘Isi Posting’)
fl=raw_input(‘Nama File’)
content=getfile(fl)+’Posted from My Mobile O2+Python
result = server.metaWeblog.getCategories(blog_id, user, passwd)

cat=raw_input(“PIlih ID Category= “)
blog_content = { ‘title’ : title, ‘description’ : content }
categories = [{‘categoryId’ : cat, ‘isPrimary’ : 1}]
#cat_id=raw_input(‘Category ID= ‘)
post_id = int(server.metaWeblog.newPost(blog_id, user, passwd, blog_content,1))
server.mt.setPostCategories(post_id, user, passwd, categories) # not work
server.mt.publishPost(post_id, user, passwd)
Posted from My Mobile O2+Python

Advertisements

Filed under: Uncategorized

One Response

  1. ipul says:

    manteb gan, kalo posting lewat php gimana ya gan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: