Forum Moderators: coopster

Message Too Old, No Replies

A simple xmlrpc encode request alternative

         

ocon

11:47 am on Oct 20, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hello,

I'm trying to change a script I've written to be used on a host that does not support the xmlrpc_encode_request function.

I use the function only once in my script, and only because a tutorial I was following had used it. My use is to prepare a few lines of content to be posted by curl.

curl_setopt($ch,CURLOPT_POSTFIELDS,xmlrpc_encode_request("blogger.newPost",array("","","username","password","<title>Title</title><category>Category 1,Category 2</category>Description of the post.",1)));

Is there something else I can use to prepare the text? Maybe using whatever the text output of the function as a template, and using that text instead?

I tried using XML-RPC for PHP but it didn't seem to work for me, and the multi megabyte files seemed overkill for my needs.

If it matters, I'm using this for a script in wordpress.

Thanks for any help.

ocon

12:02 am on Oct 21, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



At first it wasn't working, but I must have mistyped something because it works now.

curl_setopt($ch,CURLOPT_POSTFIELDS,xmlrpc_encode_request("blogger.newPost",array("","","username","password","<title>Title</title><category>Category 1,Category 2</category>Description of the post.",1)));

Seems equivalent to:

curl_setopt($ch,CURLOPT_POSTFIELDS,"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><methodCall><methodName>blogger.newPost</methodName><params>
<param><value><string/></value></param>
<param><value><string/></value></param>
<param><value><string>username</string></value></param>
<param><value><string>password</string></value></param>
<param><value><string>&#60;title&#62;Title&#60;/title&#62;&#60;category&#62;Category 1,Category 2&#60;/category&#62;Description of the post.</string></value></param>
<param><value><int>1</int></value></param>
</params></methodCall>");