Ipernity::API for Perl

posted by Doomshammer
Posted on Sunday October 12, 2008 at 13:59. 437 visits. ( permalink )
Here is my first release of the Ipernity::API framework for perl. Maybe still little bit buggy and probably there are some things to improve. Let me know your comments.

Simply download: www.pebcak.de/tmp/Ipernity-API.tar.gz

To install, simple extract the .tar.gz file, change to the new folder and run:

perl Makefile.PL
make
make test
make install


Have fun!

This topic has been edited by Doomshammer 14 months ago.

10 Replies

A Christophe Ruelle pro says:
Good news Doomshammer, I've taken a look at this package. It's very well coded. Here are my remarks :
- the authurl sub should also work without a frob. The frob is only necessary for desktop apps. This will save a preliminary/unecessary request to the API.
- the authurl should accept more permissions : perm_doc, perm_blog, perm_network & perm_profile.
- in auhtoken : why do you save $self->frob ? the frob can only be used once. Also a good idea would be to save the token.
- last thing, I don't really get how you handle errors

Anyway, I haven't tested it, just read the code. I'll give it a try on monday.
Kind regards.
Posted 14 months ago. ( permalink )
Doomshammer replies:
Thanks for the comments Christophe!

I've just updated the code and cleaned it up a bit. I will review you comments during the next days and update the package accordingly. Errors are handled now.

Winni



Changelog:
# cvs log -r 1.3 lib/Ipernity/API.pm
cvs log: nothing known about 1.3

RCS file: /wne-cvs/Ipernity-API/lib/Ipernity/API.pm,v
Working file: lib/Ipernity/API.pm
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 1
description:
----------------------------
revision 1.3
date: 2008-10-12 19:11:33 +0000; author: doomy; state: Exp; lines: +47 -35; commitid: UiqNa7UoInrW4nmt;
- Replaced Twig::XML through XML::Simple
- Cleaned up of fetchfrob() and authtoken()
- Added response verification
- Return the XML as hash via execute_xml()
=============================================================================
Posted 14 months ago. ( permalink )
Doomshammer says:
Christophe,

I've fixed the authtoken() and the authurl() permission issue. But I am getting stuck with the "non-frob" part. I actually have that part working, but if I do not issue a frob, i need to send a callback URL. Unfortunately the documentation here is not exact on how this works: www.ipernity.com/help/api/auth.web.html

Can you help me how to get the callback working with the URL? Here is what I tried:
www.ipernity.com/apps/authorize?api_key=12345670002719a49c702400051c7a&callback=http://www.heise.de&api_sig=f4c5f5f250e1af3f5bc722534554564
(Numbers in the URL have been changed)

But it is telling me s. th. in french, which I cannot translate but it looks like an error. Any idea?

Thanks
Winni
Posted 14 months ago. ( permalink )
A Christophe Ruelle pro replies:
The callback URL only works for a "Web" application and you need to configure the callback URL in the key formular - not in the permission link. Edit your key again and check it's parameters. Let me know if it's going any better...
Posted 14 months ago. ( permalink )
Doomshammer replies:
Ahhh! Got it! Thanks!
Posted 14 months ago. ( permalink )
Doomshammer says:
For the meantime here is the latest release: blog.pebcak.de/tmp/Ipernity-API-0.04.tar.gz
Posted 14 months ago. ( permalink )
Doomshammer says:
Allright, the callback URL stuff is working and verified as well.
Latest version is 0.05: blog.pebcak.de/tmp/Ipernity-API-0.05.tar.gz
Posted 14 months ago. ( permalink )
A Christophe Ruelle pro replies:
Hello Doomshammer,
I've been playing a little bit with the perl API kit. It's working great.
Here are some thoughts about it :
- why do you need to scope the API constructor arguments into 'args'=>{...}? I think a API->new({'api_key'=>"XXXX",'secret'=>"YYY",...}); would look nicer.
- it seems to me that you're not always checking the possible errors / or that it is not easy to check the error code and message returned after an execute.
- in the CheckResponse sub, you should test if status ne "ok" - it's the only way to make sure it is not "ok" ;)
- I would prefer to have the "execute" function to return : success = true/false, response (the XML), and maybe the method called + parameters. With this I'm always sure if I need to check or not the XML response. Or didn't I understand how you do that...
Anyway, here is mostly cosmetic suggestions, it's great to have you working on this perl kit.
Thanks.
Posted 14 months ago. ( permalink )
Doomshammer replies:
Thanks for the suggestions Christophe,

- The "args" part in the constructor I added actually to make the arguments sorted in a "subhash". But you are right, it might be easier to have them in the main constructor. I will change this in the next version.

- Well, that is actually what I expected. The CheckResponse() sub is meant to check for errors. If the user/programmer does like to have his own error verification, it is possible by not using the CheckResponse funciton. But all functions which provided non-raw output to the user verify the response for an error by using the CheckResonse() funciton

- Yep, the CheckReponse() ne 'ok' I already changed. I agree ;-)

- The "execute" function is actually meant to return the pure server response, so the programm has full access to it. But I will add your suggestion to the execute_xml() function which will verify the response from the server and return an hashref (I should also rename it to execute_hashref() as the _xml() is misleading).

Thanks again for your suggestions. I'll let you know when the new version is online.


Winni
Posted 14 months ago. ( permalink )
Doomshammer replies:
Ok, the other changes have been done as well. Latest version 0.06 is avail. now (via my blog and via CPAN)
Posted 11 months ago. ( permalink )

You must be logged on to post a reply. Sign in now?


rss Latest comments – Subscribe to the comment feed for this topic.

 

Català | Čeština nové | 中文 | Deutsch | English | Español | Esperanto | Ελληνικά | Français | Galego | Italiano | Nederlands | Português | More...