Wikidot API support

Status: Implemented

Created by leiger 10 Jun 2010 07:37

rating: 0+x

**STE **


wdavatar?user=leiger
leiger

12 Jun 2010 08:58. Edited 0 times. (Edit, Permalink)
Looks like this is impossible. I can get the API working in a console perfectly fine, and I can interact directly with a console from STE, but when it comes to opening up the Python interactive console it all goes up in the air and apparently Java just simply won't work.

It would have to be a completely different program, written exclusively in Python. Or "Jython", which still won't work with STE.

Though not all avenues have been crossed off yet. Still asking around…

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

12 Jun 2010 09:06. Edited 1 times. (Edit, Permalink)
I'm using a PHP class for XML-RPC… don't know for JAVA :-)
EDIT: Have you had a look at this: http://www.ibm.com/developerworks/xml/library/j-xmlrpc.html

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

12 Jun 2010 23:29. Edited 1 times. (Edit, Permalink)
Had a quick look at the article and was confused by most of it. Will have a proper read through it as soon as I can.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

13 Jun 2010 00:59. Edited 0 times. (Edit, Permalink)
Maybe you can have a look at this: http://sourceforge.net/projects/sandler/

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

13 Jun 2010 08:11. Edited 0 times. (Edit, Permalink)

tsangk wrote:
Maybe you can have a look at this: http://sourceforge.net/projects/sandler/

If I understand why you posted that, then it would help me to add this feature: thread:58

Not sure why you posted it in this thread though? I've done a few searches and can't find any link between Python and the Atom Sandler toolkit.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

13 Jun 2010 10:00. Edited 1 times. (Edit, Permalink)
Wikidot's API uses XML-RPC (i.e. not Python). Python scripts can be used to access the API however you can use any tool (no Python required) to access…

The script I use in my Package Installer doesn't use any Python scripts at all! Look at it:

<?php
function wikidotpage($site,$category,$source,$title,$parent_page,$tags)
{
$site=str_replace(" ","-",$site);
$category=str_replace(" ","-",$category);
$requestarray=array(
    'site'=>$site,
    'page'=>$category,
    'source'=>$source,
    'title'=>$title,
    'tags'=>$tags,
    'parent_page'=>$parent_page
);
$request = xmlrpc_encode_request("page.save",$requestarray);
$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "Content-Type: text/xml",
    'content' => $request
)));
$file = file_get_contents("https://username:[email protected]/xml-rpc-api.php", false, $context);
$response = xmlrpc_decode($file);
if ($response && xmlrpc_is_fault($response)) {
    trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
 
return $response;
}
}
?>

In conclusion:

  • Python is just ONE method of interaction with the API
  • You can use many different stuff (I don't know if the links above will help you)
  • Usually, If you look for keywords like "java blogger api" you can find similar code which you can edit for Wikidot (that's what I did with my PHP script)

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

13 Jun 2010 12:12. Edited 0 times. (Edit, Permalink)
I only vaguely know what XML-RPC is, as it has come up in my reverse engineering course but not in any great detail… just mentioned in passing. I had wrongly assumed that Python was the only way to access the API! ;-)

Now that you've told me otherwise, I'm finding some useful results in Google, as I have a better idea of what keywords to use. I'll also read those links you gave me again, to see if they make any more sense.

Thanks!

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

19 Jun 2010 09:56. Edited 0 times. (Edit, Permalink)
What would be the best way to implement this?

I'm thinking that there could be a toggle between "offline mode" and "online mode" for STE, where in offline mode the save button saves to the computer and in online mode it saves to Wikidot (popup asking you what page name to save it to)

Can you think of a better way to do it, that will still be easy to understand for new users of STE ?

Included page "inc:signature" does not exist (create it now)

wdavatar?user=
(user deleted)

19 Jun 2010 16:04. Edited 0 times. (Edit, Permalink)
I would not use a toggle for offline/online - that seems like it could be a bit dangerous if you're not paying attention to what mode you're in. I think you need specific menu options to handle any interaction with Wikidot. Something like "import/export" or "open from/save to" with specific menu options.

  • File
    • Open
    • Save
    • Import from Wikidot
    • Export to Wikidot

I think having those options available as part of the open or save as… dialogs could work well too.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

20 Jun 2010 00:47. Edited 0 times. (Edit, Permalink)
Ah! Good idea.

Yes, "Import" and "Export" would be a good idea.

The only thing I'd need to figure out from a technical standpoint is how I'll handle the page title, tags, parent page, etc, etc… I'd need two different modes in the backend, so that if it was in online mode I'd store that extra info, and offline mode I'd store a filename instead.

If someone clicks on "Open" it opens the file in offline mode, if they click on "Import" it opens it in online mode. That way I know what variables to look for.

Unless… would you want to be able to change the parent page, tags, title, etc even when offline? One benefit to that is that you can just click "export" and specify a page name - and that's it.

The negative impact of that is that it makes it a bit more complicated - people aren't used to seeing that in a regular text editor, so the learning curve coming from something like notepad (windows) or gedit (linux) would be increased. I'd also have to store the information somewhere… perhaps just a box similar to Tools > Statistics, that shows you the page's tags and parent and other meta information and lets you change it.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

20 Jun 2010 01:03. Edited 0 times. (Edit, Permalink)
I would create a new extension with an XML based format…. something like this:

<stefile>
<pagename>category:page</pagename>
<title>STE Testing</title>
<tags>tag1 tag2 _tag-with-underscore</tags>
<parentpage></parentpage>
<content>
Lorem ipsum......
//blah// is italic.  **George** is bold!
</content>
</stefile>

When loaded inside STE… the config will be automatically loaded… selecting export will generate a pop-up with text boxes with the config pre-defined however the user can change it.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

20 Jun 2010 01:14. Edited 0 times. (Edit, Permalink)
Good idea.

I'd have to take into account reading plain text files with the .ste extension as well, but I can make it always save as XML. That'll mean that any STE files created before I add in this xml structure will still work.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=
(user deleted)

23 Jun 2010 02:24. Edited 0 times. (Edit, Permalink)
While browsing the book section of my favorite computer store today, a book about Jython caught my eye and I immediately thought of the STE project. I just did some quick searching and found The Jython Project. The $40+ book is available in an open source version!
Here's a snippet from the introduction:

Jython provides easy integration and interoperability between Python code and existing Java code. Jython also has something to offer existing Python programmers, namely access to the very rich ecosystem of the Java Virtual Machine. There is an enormous amount of Java code out in the world. There are libraries for every task imaginable, and more. Jython gives Python programmers a way to tap into these libraries, saving both development and testing time.

I need to dust off the little bit I learned about Python since I got bored waiting for the save method to be made available for the API. Now that it's here, we can probably start to do really some useful stuff. It sounds like Jython might be a slick way for you to access the API using Java.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

23 Jun 2010 03:59. Edited 0 times. (Edit, Permalink)
I'm working on a way to access the API directly with Java at the moment. Having some success, but no breakthroughs yet.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

23 Jun 2010 06:55. Edited 0 times. (Edit, Permalink)
Shane… I suggest you have a look at this page:
http://www.franzone.com/2007/08/03/would-you-like-to-post-to-wordpress-from-java/

I think it has exactly what you need :-)

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

24 Jun 2010 00:53. Edited 1 times. (Edit, Permalink)
Redstone doesn't have the correct JAR files that I needed. I ended up going with Apache XML-RPC as that seemed to be the best, then adding in a few extra JAR files that it didn't seem to have yet.

I'm able to connect to the Wikidot API, but am having issues figuring out how to authenticate myself with my username and API key. The 'Authenticate' class in Java doesn't seem to be working as advertised :P

Thanks for that link though - I'll bookmark it. It'll probably be useful later once I can authenticate :S

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

24 Jun 2010 06:48. Edited 0 times. (Edit, Permalink)
Can't you do that through the url? http://username:key@wikidot...

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

24 Jun 2010 13:11. Edited 2 times. (Edit, Permalink)
Nope, doesn't seem to work. Tried that first.

EDIT: But I did spend at least a week to get the "unauthorised" message :P So before I wasn't even reaching the server… whereas now I am. Maybe if I try it again it might work…

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

27 Jun 2010 05:10. Edited 3 times. (Edit, Permalink)
Looks like I've been using the username:key@wikidot method for a while. I had a look at the code and that's how I was already doing it.

I think I got the idea for the 'Authenticate' class from some documentation on XML-RPC being used with Java…

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

27 Jun 2010 05:24. Edited 0 times. (Edit, Permalink)
So the Authenticate thru URL method is working?

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

27 Jun 2010 05:49. Edited 0 times. (Edit, Permalink)
No it's not — and that's the problem :(

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

27 Jun 2010 06:26. Edited 0 times. (Edit, Permalink)
That's the annoying part. It's not working for Javascript either.

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

27 Jun 2010 08:41. Edited 0 times. (Edit, Permalink)
Twitter has what looks like hundreds of libraries divided into about 20 different languages.

One day Wikidot will have similar support … and using the API will be easy XD If I can figure out how to get it working, I'll make a Java library myself!!

Included page "inc:signature" does not exist (create it now)

wdavatar?user=tsangk
tsangk

27 Jun 2010 10:17. Edited 0 times. (Edit, Permalink)
Maybe I can make a PHP one :P
I just had an idea - from ages ago that I wanted to implement once the API was released….

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

27 Jun 2010 15:11. Edited 0 times. (Edit, Permalink)
I'm intrigued…

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

09 Jul 2010 13:53. Edited 0 times. (Edit, Permalink)
This has been IMPLEMENTED in Version 2.0.

Included page "inc:signature" does not exist (create it now)

Post Reply

Add reply on "Wikidot API support"

CSS Theme, Images and Code on this website are © Shane Smith 2010-2012. All forum posts by users and documentation licensed under Creative Commons BY-NC-SA 3.0 License.