A perl implementation of the livejournal protocol
use LiveJournal; my %info = ( user => 'foo', password => 'bar', ); my $lj = LiveJournal->new(\%info); my $response = $lj->login(); print "Logged in successfully\n" if ($response->{success} eq "OK"); ... my $friend = LiveJournal::Friend->new(); my $response = $friend->check(); ... my $journal = LiveJournal::Journal->new(); my $response = $journal->syncitems();
This module is implements the LiveJournal protocol. See http://www.livejournal.com/developer/protocol.bml for details. Data is requested from the server through mode lines. Many methods return a hash reference containing key/value pairs returned by the server. Descriptions of possible responses can be found at http://www.livejournal.com/developer/modelist.bml
This is the constructor for a new LiveJournal object. \*(C`INFO\*(C' is a hash containing at least username and password (plaintext) or hpassword (\s-1MD5\s0 hash) key/value pairs. You may also include a \s-1URL\s0, for which the default is http://www.livejournal.com/cgi-bin/log.cgi. To use a proxy, add a proxy key and value.
If you want to use a file in the livejournalrc format to store your data, you can use this method instead. \*(C`FILES\*(C' is an array reference to the file(s) you want to load. If you don't specify any, it will use the first one found of ~/.livejournalrc, ~/.livejournal.rc, or /etc/livejournalrc. This will return an object in the LiveJournal class.
Log in to the LiveJournal server. Returns a hash reference. The server returns whether the password is good or not, the user's name, an optional message to be displayed to the user, and the list of the user's friend groups. \*(C`INFO\*(C' is an optional hash reference containing the optional keys getmoods, getmenus, and getpickws. getmoods should exist and be the number of the highest mood \s-1ID\s0 you have cached/stored on the user's computer. For example, if you logged in last time with and got mood IDs 1, 2, 4, and 5, then send \*(L"5\*(R" as the value of \*(L"getmoods\*(R". The server will return every new mood that has an internal MoodID greater than 5. If you've never downloaded moods before, send \*(L"0\*(R". getmenus should exist if you want to get a list/tree of web jump menus to show in your client. getpickws should exist if you want to receive that list of picture keywords.
Returns the username
Returns the password or hpassword, whichever is set.
Returns the version string. You may alter the version string by passing a \*(C`VERSION\*(C'.
Sets/returns the journals that the user has the ability to post to. This method is called automatically by \*(C`parse_login()\*(C'. It returns a list reference containing each journal.
Sets/returns the friend group information. This method is called automatically by \*(C`parse_login()\*(C'. It returns a hash of hashes containing name and sortorder key/value pairs. We use a hash instead of an array here because the group numbers start from 1 and it seemed more appropriate than having an undef 0 element or requiring adding 1 all the time.
Sets/returns the maximum friend_group number. This method is called automatically by \*(C`parse_login()\*(C'.
Sets/returns the menu text and \s-1URL\s0 information. This method is called automatically by \*(C`parse_login()\*(C'. You can use the list of lists of hashes it returns as data for menus.
Sets/returns the mood information. This method is called automatically by \*(C`parse_login()\*(C'. Returns a list of hashes containing the keys id and name for each mood.
Sets/returns the number of moods. This method is called automatically by \*(C`parse_login()\*(C'.
Sets/returns the name of the the logged in user. This method is called automatically by \*(C`parse_login()\*(C'.
Sets/returns the picture keywords. This method is called automatically by \*(C`parse_login()\*(C'. Returns a reference to a list of the keywords.
Use this method to escape strings. \*(C`STRING\*(C' is any string. All non-alphanumeric characters and non-whitespace are converted to their %hex values. Spaces are converted to +s.
Poll the server to see if the friends list has been updated. This request is extremely quick, and is the preferred way for users to see when their friends list is updated. Returns a hash reference.
Takes two optional arguments. If \*(C`FRIENDOF\*(C' is set to 1, you will also get back the info from the \*(L"friendof\*(R" mode. If \*(C`GROUPS\*(C' is set to 1, you will get the info from the \*(L"getfriendgroups\*(R" mode. This method returns a hash reference which should be passed to parse() to be more useful. \s-1YOU\s0 \s-1SHOULD\s0 \s-1ALWAYS\s0 \s-1USE\s0 \s-1THIS\s0 \s-1METHOD\s0 \s-1BEFORE\s0 \s-1VIEWING\s0 \s-1AND\s0 \s-1AFTER\s0 \s-1MODIFYING\s0 \s-1YOUR\s0 \s-1FRIENDS\s0 \s-1LIST\s0 \s-1TO\s0 \s-1AVOID\s0 \s-1INCONSISTENCIES\s0.
Takes one argument: the hash reference returned from get(). Returns a hash of lists of hashes containing the info (user, name, fg, bg, etc) for each friend such as: 'friend' =>
[ { 'fg' => '#000000', 'bg' => '#FFFFFF', 'groupmask' => '3', 'user' => 'SomeUser', 'name' => 'Some X. Name' } ]
You should call parse() anytime you call get() to keep your friend count up to date.
This method is used to add and edit friends to your friends list. It takes a hash of hash references structure which has the username as the first level of keys. The second level contains optional fg and bg colors in #RRGGBB format. 'newfriend' =>
{ 'fg' => '#000000', 'bg' => '#FFFFFF', }
newfriend is the name of the new user. number should be the sum of \*(C`numfriends() + n\*(C' where n is incremented for each friend you are adding.
Use this method to add a user from your friends list. \*(C`FRIEND\*(C' is a username. \*(C`FG\*(C' and \*(C`BG\*(C' are foreground and background values in #RRGGBB format.
Use this method to remove users from your friends list. Pass it an array reference containing usernames. Returns a hash reference.
This method returns a hash reference of the users that list you as a friend. This hash reference can be passed to parse().
Returns or sets the last time check was used. check() sets this value so you don't have to.
This method sets and returns the number of friends you have. It is automatically called from parse() so you shouldn't have to worry about setting it manually.
Sets and returns your friends list. This method is called by \*(C`parse()\*(C' automatically to propagate the hash.
This method returns a hash reference containing information about your friend groups
Use this method to create or edit a friend group. You can modify the name, sort order, and public attributes of the group by passing a hashref containing the keys called name, sort, or public and respective new values. You can also add a friend to a group or groups by passing their username as a key and the new groupmask as a value.
This method deletes a friend group. Pass it an array reference containing the numbers of the groups to delete.
Returns a hash of list references containing users and the groups they are members of.
Use this method to add a friend to a user group. \*(C`USER\*(C' is the username of the person and \*(C`GROUP\*(C' is the group number.
Use this method to remove a friend from a user group. \*(C`USER\*(C' is the username of the person and \*(C`GROUP\*(C' is the group number.
Use this method to download parts of a user's journal. \*(C`INFO\*(C' is a hash reference containing at least a key called selecttype and a value of either syncitems, day, lastn, or one. syncitems will use the \*(C`lastcync()\*(C' method by default, otherwise pass it a date in the yyyy-mm-dd hh::mm::ss format. If you use day, you may provide year, month, and day keys to specify which day. Default is today. The lastn value requires a howmany key which says how many of the most recent items to download. Maximum is 50. Default is 20. If you want a particular entry, you should use the one value and a complimentary itemid key containing the id of the item you want to grab. For further detail, see http://www.livejournal.com/developer/modeinfo.bml?getevents
This method is used to post a journal entry. \*(C`INFO\*(C' is a hash reference containing at least an event key with a value of the post content. The date keys are created for you. For further detail, see http://www.livejournal.com/developer/modeinfo.bml?postevent
Used to edit user's past journal entry. \*(C`INFO\*(C' is a a hash reference containing at least the itemid and event being submitted. Other optional values are documented at http://www.livejournal.com/developer/modeinfo.bml?editevent
Used to delete a past journal entry. \*(C`ITEMID\*(C' is a scalar containing the unique item id to delete.
Returns a hash reference containing items (journal entries, to-do items, comments) that have been created or updated on LiveJournal since you last downloaded them.
Returns or sets the last time syncitems() was used. syncitems() sets this value so you don't have to.
This mode retrieves the number of journal entries per day. Useful for populating calendar widgets in \s-1GUI\s0 clients.
Frank Sheiness <[email protected]> http://feeding.frenzy.com/~rainking/
Brad 'bradfitz' Fitz <[email protected]> for unconfusing me
Joe 'pinman' Wreschnig <[email protected]> for his idea providing ventures into Perl-LiveJournal land
http://forbidden.dough.net/~archon/lj/
perl\|(1).
http://www.livejournal.com/developer/