Phoenix Path (fallen_x_ashes) wrote in lj_clients,
Phoenix Path

  • Mood:

Using Python and XMLRPC to post to LJ

I'm VERY new at this. (Both to using XMLRPC and Python, infact I wouldn't say I really know what I'm doing, merely coding from imitation and some basic knowledge of the general syntax of most programming languages.) Basically I started doing this when it seemed like the Blogger API had been removed from Livejournal. I couldn't make a post using it. So, I set about altering my application to use the LiveJournal XMLRPC. It's a very quick and dirty hack, I'm passing passwords in the clear essentially. I'm VERY close, it works for LJ.XMLRPC.login, but when I try LJ.XMLRPC.postevent I get the following error message:

XML-RPC Fault: ServerCan't use string ("1") as a HASH ref while "strict refs" in use at /home/lj/cgi-bin/ line 2527, [anglebracket]GEN2[anglebracket] line 41.

I added the [anglebracket] thing there. The line number following Gen2 changes with each try, so I'm not sure if it really matters. Here's the Code for the function responsible for creating the post:

def newPostLiveJournal(logger, audioFilePath, cgiAudioFilePath, AuthMethod, LineEndings,
xmlrpcServer, blogID, userName, password, publish, useNewMediaObject, nmoDestPath):
"""Adds a new post to a LiveJournal"""

logger.write('In newPostLiveJournal\n')
postID = {}
postID['itemid'] = -1
LJEvent = {}
LJEvent['username'] = userName
LJEvent['auth_method'] = AuthMethod
LJEvent['password'] = password
LJEvent['event'] = '

This post was created with PhoneBlogger. ' \
+ 'Click to listen to the ' \
+ 'recorded message.

LJEvent['lineendings'] = LineEndings
LJEvent['subject'] = 'Post from PhoneBlogger'
LJEvent['year'] = time.localtime()[0]
LJEvent['mon'] = time.localtime()[1]
LJEvent['day'] = time.localtime()[2]
LJEvent['hour'] = time.localtime()[3]
LJEvent['min'] = time.localtime()[4]
logger.write('Set LJEvent\n')
postID = xmlrpcServer.LJ.XMLRPC.postevent(LJEvent and xmlrpclib.True or xmlrpclib.False)
except xmlrpclib.Fault, fault:
logger.write('XML-RPC Fault: ' + fault.faultCode + fault.faultString + '\n')
return postID['itemid']

Does anyone have any ideas as to what could be wrong, or how I can go about debugging this?

  • 302: lj_dev

    In the interests of consolidating all LiveJournal development-related discussion, we're going to be closing down this community. The same…

  • Plain text to LJ

    I have an old blog from xanga that's in html/plain text and I want to move it over here. Which client would be the best to do this? I also want to…

  • ljKlient 0.2.0 Preview Release 1

    Today marks another milestone in the development of ljKlient — as the first preview of the 0.2 series is released.  Please go to the project…

  • Post a new comment


    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened