Need help with API & XMLRPC | Frequently Asked Questions - All in One SEO Pack Pro | Support | Semper Plugins

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Need help with API & XMLRPC
November 29, 2012
10:46 pm
Avatar
pokerdawg
Member
Guests
Forum Posts: 6
Member Since:
November 29, 2012
sp_UserOfflineSmall Offline

I bought the pro version specifically to access the API described on the product page. However, now that I have the pro version, I can’t find any documentation on using the API

I am trying to do it under wp.newPage and wp.editPage with custom_fields but haven’t had any success.

Is this the right approach? Should I be calling something other than wp.newPage and wp.editPage? If so what?

Can you provide any examples? All I want to do is set the title, description & keywords for a new page and post I’ve pushed to the site.

Thanks

November 30, 2012
7:14 am
Avatar
pokerdawg
Member
Guests
Forum Posts: 6
Member Since:
November 29, 2012
sp_UserOfflineSmall Offline

Also, I’ve tried searching, but the forum doesn’t allow me to search for “API”, “XML” or “RPC” as search terms have to be a minimum of 4 characters (of course) and the searches for “XMLRPC” show very limited results.

November 30, 2012
9:52 am
Avatar
Peter Baylies
Admin
Forum Posts: 578
Member Since:
October 16, 2011
sp_UserOfflineSmall Offline

** You currently do not have permission to see this post. To obtain access to these Premium Support Forums, please purchase a plugin and support subscription from Semper Plugins **

November 30, 2012
10:48 am
Avatar
pokerdawg
Member
Guests
Forum Posts: 6
Member Since:
November 29, 2012
sp_UserOfflineSmall Offline

Still no luck.

I’m interfacing via Cold Fusion and everything works with the psots – except these 3 custom fields. The posts are going live OK.

Below is the code I’m using. Even if you don’t speak ColdFusion, it is obvious what is happening & I’ve documented the heck out of it. Do you see anything wrong?

(Also, for anyone doing ColdFusion, there is no good documentation out there about using the WordPress API with CFM, so feel free to reuse the code below… it works like a charm on the posting of Pages & Posts)

[REMOVED BY ADMIN – SEE UPDATED VERSION BELOW]

November 30, 2012
11:22 am
Avatar
pokerdawg
Member
Guests
Forum Posts: 6
Member Since:
November 29, 2012
sp_UserOfflineSmall Offline

OK, I got it to work. I did an XML dump of what was produced and, surrounding the custom fields and their values were tags KEY and VALUE. They need to be lower case, not upper case. Also, for whatever reason, the key values in the structures were not being reset each time, so that the keyword custom field was being presented 3 times instead of keyword, title, description.

Below is the working version for anyone it may help.

<body style=”font-family: calibri, arial;”>
<cfoutput>

<!— Define the blog and credentials ——————–>
<cfset theblog = “my.domain.name”>
<cfset username = “my-username”>
<cfset password = “my-password”>

<!— Create the ARRAY to post to the API —————->
<cfset myArray = ArrayNew(1)>

<!— Add the method, blogID, username, password to the array —————->
<cfset temp = ArrayAppend(myArray, “wp.newPost”)>
<cfset temp = ArrayAppend(myArray, “1”)>
<cfset temp = ArrayAppend(myArray, “#username#”)>
<cfset temp = ArrayAppend(myArray, “#password#”)>

<!— Creates a “now” variable to put into blog titles, so we can differentiate between repeated test posts —>
<cfset now = LSTimeFormat(now(),”HH:mm:ss”)>

<!— Start creating the content STRUCTURE which eventually gets added to the array ————>
<CFSET content = structnew()>
<CFSET content[“post_type”]=”page”>
<CFSET content[“post_status”]=”publish”>
<CFSET content[“post_title”]=”Test post title #now#”>
<CFSET content[“post_author”]=”1″>
<CFSET content[“post_excerpt”]=”This is the excerpt #now#”>
<CFSET content[“post_content”]=”<h1>Start of content</h1>This is the content #now# for this article.”>
<CFSET content[“post_date”]=”#LSDateformat(now(),”mm/dd/yyyy”)# #LSTimeformat(now(),”HH:mm:ss”)#”>
<CFSET content[“post_format”]=””>
<CFSET content[“post_name”]=”the-slug-#lstimeformat(now(),”HHmmss”)#”><!— name = SLUG for the post/page —>
<CFSET content[“comment_status”]=”closed”>
<CFSET content[“ping_status”]=”closed”>
<CFSET content[“sticky”]=”false”>
<CFSET content[“post_parent”]=”17″>
<CFSET content[“menu_order”]=”10″>
<CFSET content[“post_password”]=””>
<CFSET content[“tags_input”]=”tag1,tag2,tag3″>

<!— Create an ARRAY to hold the custom fields ————————————————>
<cfset customfieldsarray = arraynew(1)>

<!— Create the STRUCTURE that will be used to hold the key/value pairs ———————–>
<cfset t1 = structnew()>
<cfset t2 = structnew()>
<cfset t3 = structnew()>

<!— Assign and append the first pair – the Title – to the customfieldsarray ——————>
<cfset t1.key = “_aioseop_title”>
<cfset t1.value = “This is the title”>
<cfset temp = arrayappend(customfieldsarray, t1)>

<!— Assign and append the second pair – the Title – to the customfieldsarray ——————>
<!— note: overwriting values in current STRUCTURE named “T” ———————————–>
<cfset t2.key = “_aioseop_description”>
<cfset t2.value = “This is the description”>
<cfset temp = arrayappend(customfieldsarray, t2)>

<!— Assign and append the third pair – the Keywords – to the customfieldsarray —————->
<!— note: overwriting values in current STRUCTURE named “T” ———————————–>
<cfset t3.key = “_aioseop_keywords”>
<cfset t3.value = “keyword1,keyword2,keyword3”>
<cfset temp = arrayappend(customfieldsarray, t3)>

<!— Now append that array to the STRUCTURE named “CONTENT” with the key “CUSTOM_FIELDS” ——->
<CFSET content[“custom_fields”]=customfieldsarray>

<!— Now append the STRUCTURE named “CONTENT” to the ARRAY named “myArray” ———————>
<cfset temp = ArrayAppend(myArray, content)>
<cfset temp = ArrayAppend(myArray, “true”)><!— Publish – BOOL —>

<!— Convert the CFML array to XMLRPC ———————————————————->
<cfset xmlString = cfc.xmlrpc.CFML2XMLRPC(myArray)>

<!— CRITICAL ——————————————————————————————–>
<!— The above results in VALUE and KEY being used on the custom fields. They need to be lower case!!! —>
<!— CRITICAL ——————————————————————————————–>

<cfset xmlstring = replace(xmlstring,”VALUE”,”value”,”ALL”)>
<cfset xmlstring = replace(xmlstring,”KEY”,”key”,”ALL”)>

<cfhttp method=”post” url=”http://#TheBlog#/xmlrpc.php” result=”myResult” >
<cfhttpparam type=”xml” value=”#xmlString#”>
</cfhttp>

#htmleditformat(xmlstring)#

<!— Convert the Response from XMLRPC to CFML and display on screen —————————->
<cfset myCFMLResult = cfc.xmlrpc.XMLRPC2CFML(myResult.fileContent)>
<pre>#htmleditformat(myResult.fileContent)#</pre>
<cfdump var=”#myresult#”>

</cfoutput>
</body>

November 30, 2012
11:49 am
Avatar
Peter Baylies
Admin
Forum Posts: 578
Member Since:
October 16, 2011
sp_UserOfflineSmall Offline

** You currently do not have permission to see this post. To obtain access to these Premium Support Forums, please purchase a plugin and support subscription from Semper Plugins **

Forum Timezone: America/New_York

Most Users Ever Online: 964

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Member Stats:

Guest Posters: 35

Members: 18919

Moderators: 0

Admins: 8

Forum Stats:

Groups: 4

Forums: 28

Topics: 1822

Posts: 7732

Newest Members:

mliebethal

Administrators: Michael TorbertPeter BayliesSupport TeamSteve MortiboyMatthew RobinsonSteve KlasenArnaud BroesAsh R

[i]
[i]
Skip to toolbar