XML-RPC

Peter Haworth pete at lcsql.com
Mon Nov 16 17:16:59 EST 2015


Thanks Jose.  That's pretty much what I'm doing but I get an error 400 back
from the server (I think the text is "unknown method" or something similar.

I have moved on to using curl to get what I need.  The third party had some
docs on how to do that so I use shell() to issue the curl command with the
output redirected to a file which I then read to get the output of the
command.  Seems to be working fine so far.


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Mon, Nov 16, 2015 at 2:05 PM, José Antonio Rocha <
joseantoniorocha at gmail.com> wrote:

> 2015-11-15 15:48 GMT-02:00 Peter Haworth <pete at lcsql.com>:
>
> > This looks like the server side of things and I'm
> > looking for examples of using the revXMLRPC@ calls from a Livecode
> desktop
> > app.
> >
>
> ​Here is my getPost WordPress function:
>
> ---------------------------
> -- GET POST
> ---------------------------
> /*
> -- Fields to return (optionals):
> string post_id, string post_title, datetime post_date, datetime
> post_date_gmt,
> datetime post_modified, datetime post_modified_gmt, string post_status,
> string post_type, string post_format, string post_name, string post_author,
> string post_password, string post_excerpt, string post_content, string
> post_parent
> string post_mime_type, string link, string guid, int menu_order, string
> comment_status,
> string ping_status, boolean sticky, struct post_thumbnail [lack support,
> yet],
> array terms (string term_id, string name, string slug, string term_group,
> string term_taxonomy_id, string taxonomy, string description,
> string parent, int count ), array custom_fields (id, key, value),
> array enclosure (url, length, type)
> */
> function wp.getPost pPostID pFieldsA
>    global gDebug
>    global gServer, gPort, gXmlrpcPath, gProto, gBlogID
>    local tID, res, lPostContentA,tMembersNum, tMemberPath, tName
>    local tCustomPath, tCustomNum, tCustomStructPath, tTemp, tCustomName,
> tCustomValue
>    local tTermsPath, tTermsNum, tTermMembersPath, tTermMembersNum,
> tTermName
>    local tTermStructChildPath, tTermValue, tEnclosurePath, tEnclosureName
>    local tEnclosureChildPath, tEnclosureValue, tValuePath, tValue
>
>    put revXMLRPC_CreateRequest(gServer, gPort, gXmlrpcPath, gProto) into
> tID
>    revXMLRPC_SetMethod tID, "wp.getPost"
>    revXMLRPC_AddParam tID, "int", gBlogID -- this don't select the blog but
> is neccessary
>    XMLRPC_AddUser tID
>    -- Set the post to retrieve
>    revXMLRPC_AddParam tID, "int", pPostID
>    -- Set optional fields to retrieve
>    revXMLRPC_AddParam tID, "array", pFieldsA
>    XMLRPC_SetAuthorization tID
>    -- Retrieve
>    put revXMLRPC_Execute(tID) into res
>    //put revXMLText(res) into gDebug ----------------debugging
>    revDeleteXMLTree tID
>    Err res
>    -- Build an array with posts data
>    -- This path refers to structure of returned XML
>    put revXMLnumberOfChildren(res,
> "/methodResponse/params/param/value/struct/","member", 1) into tMembersNum
>    repeat with x = 1 to tMembersNum
>       put format("/methodResponse/params/param/value/struct/member[%s]/",
> x) into tMemberPath
>       put revXMLNodeContents(res, (tMemberPath & "name")) into tName
>       if tName is "custom_fields" then
>          put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/",x)
> into tCustomPath
>          put revxmlnumberofchildren(res, tCustomPath,"value", 1) into
> tCustomNum
>          repeat with y = 1 to tCustomNum
>             put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/value[%s]/struct/",
> x,y) into tCustomStructPath
>             -- Get the fields: "id", "key", "value"
>             repeat with z = 1 to 3
>                put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/value[%s]/struct/member[%s]/",
> x,y,z) into tTemp
>                put revXMLNodeContents(res, (tTemp & "name")) into
> tCustomName
>                put revXMLNodeContents(res, (tTemp & "value/string")) into
> tCustomValue
>                put textDecode(tCustomValue,"UTF-8") into
> lPostContentA[tName][y][tCustomName]
>             end repeat
>          end repeat
>          next repeat
>       end if
>       if tName is "terms" then
>          put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/",x)
> into tTermsPath
>          put revxmlnumberofchildren(res, tTermsPath,"value", 1) into
> tTermsNum
>          repeat with y = 1 to tTermsNum
>             put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/value[%s]/struct/",
> x,y) into tTermMembersPath
>             put revxmlnumberofchildren(res, tTermMembersPath,"value", 1)
> into tTermMembersNum
>             repeat with z = 1 to tTermMembersNum
>                put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/array/data/value[%s]/struct/member[%s]/",
> x,y,z) into tTemp
>                put revXMLNodeContents(res, (tTemp & "name")) into tTermName
>                put revXMLFirstChild(res,(tTemp & "value")) into
> tTermStructChildPath
>                put revXMLNodeContents(res, tTermStructChildPath) into
> tTermValue
>                put textDecode(tTermValue,"UTF-8") into
> lPostContentA[tName][y][tTermName]
>             end repeat
>          end repeat
>          next repeat
>       end if
>       -- WP return just one enclosure. It apears in custom fields, too.
>       if tName is "enclosure" then
>          put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/struct/",
> x) into tEnclosurePath
>          -- Get the fields: "url", "length", "type"
>          repeat with y = 1 to 3
>             put
>
> format("/methodResponse/params/param/value/struct/member[%s]/value/struct/member[%s]/",
> x,y) into tTemp
>             put revXMLNodeContents(res, (tTemp & "name")) into
> tEnclosureName
>             if tEnclosureName is not empty and not(tEnclosureName begins
> with "xmlerr,") then
>                put revXMLFirstChild(res,(tTemp & "value")) into
> tEnclosureChildPath
>                put revXMLNodeContents(res, tEnclosureChildPath) into
> tEnclosureValue
>                put textDecode(tEnclosureValue,"UTF-8") into
> lPostContentA[tName][tEnclosureName]
>             end if
>          end repeat
>          next repeat
>       end if
>       -- (TODO: post_thumbnail support)
>       -- If is any other field type:
>       ---- revXMLFirstChild get any type (string, boolean, array, int, i4,
> dateTime.iso8601, struct)
>       put revXMLFirstChild(res,(tMemberPath & "value")) into tValuePath
>       put revXMLNodeContents(res, tValuePath) into tValue
>       put textDecode(tValue,"UTF-8") into lPostContentA[tName]
>    end repeat
>    return lPostContentA
> end wp.getPost
>>
>
>
> --
> [image: Meira]
> ------------------------------
> nome: "José Antonio Meira da Rocha
> <https://plus.google.com/+JoséAntonioMeiradaRocha/
> <https://plus.google.com/+Jos%C3%A9AntonioMeiradaRocha/>>"
> email: joseantoniorocha at gmail.com
> veículo: [ http://meiradarocha.jor.br ]
> fones: [ 55-8448-3866  55-3744-2994 ] 🐊
> ------------------------------
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list