<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: jaiku code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 23:52:50 GMT</pubDate>
    <description>DZone Snippets: jaiku code</description>
    <item>
      <title>Twitter and Jaiku from the command line</title>
      <link>http://snippets.dzone.com/posts/show/5265</link>
      <description>The following instructions make it easy to post to Twitter and Jaiku from the command line. The instructions were copied from the article &lt;a href="http://snipr.com/22b38"&gt;"Ubuntu Unleashed: Howto Twitter From the Command Line in Ubuntu!"&lt;/a&gt;  [ubuntu-unleashed.com] and modified to post via Rorbuilder's ProjectX API.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;sudo apt-get install curl&lt;/code&gt;&lt;br /&gt;&lt;code&gt;sudo gedit /usr/bin/jaitwit&lt;/code&gt;&lt;br /&gt;Now Paste this in gEdit and simply replace "YourUsername" with your username and "YourPassword" with your twitter passwd, then replace the Jaiku variables (YourUsername, YourPassword, YourCity, YourAccessKey) and ctrl-s to save, then alt-F4 to exit!&lt;br /&gt;&lt;code&gt;&lt;br /&gt;curl http://rorbuilder.info/api/projectx.cgi?xml_project=%3Cproject%20name=%22micro_blog%22%3E%3Cmethods%3E%3Cmethod%20name=%22post2jaiku%22%3E%3Cparams%3E%3Cparam%20var=%22user%22%20val=%22YourUsername%22/%3E%3Cparam%20var=%22msg%22%20val=%22`echo $@|tr ' ' '+'`%22/%3E%3Cparam%20var=%22location%22%20val=%22YourCity%22/%3E%3Cparam%20var=%22apikey%22%20val=%22YourAccessKey%22/%3E%3C/params%3E%3C/method%3E%3Cmethod%20name=%22post2twitter%22%3E%3Cparams%3E%3Cparam%20var=%22user%22%20val=%22YourUsername%22/%3E%3Cparam%20var=%22msg%22%20val=%22`echo $@|tr ' ' '+'`%22/%3E%3Cparam%20var=%22password%22%20val=%22YourPassword%22/%3E%3C/params%3E%3C/method%3E%3C/methods%3E%3C/project%3E -o /dev/null&lt;br /&gt;echo Message Sent!&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then chmod for exec privileges:&lt;br /&gt;&lt;code&gt;chmod +x /usr/bin/jaitwit&lt;/code&gt;&lt;br /&gt;Then from the CLI type jaitwit followed by your message.&lt;br /&gt;&lt;code&gt;jaitwit "message here without the quotes"&lt;/code&gt;</description>
      <pubDate>Fri, 21 Mar 2008 18:28:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5265</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Post to Jaiku using PHP</title>
      <link>http://snippets.dzone.com/posts/show/5259</link>
      <description>This example uses the ProjectX API to post to Jaiku.com&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;  $msg = 'this is just a test message using the ProjectX API for posting to Jaiku';&lt;br /&gt;&lt;br /&gt;  $xml_result =  simplexml_load_file('http://rorbuilder.info/api/projectx.cgi?xml_project=&lt;project name="jaiku"&gt;&lt;methods&gt;&lt;method name="post"&gt;&lt;params&gt;&lt;param var="user" val="jrobertson"/&gt;&lt;param var="msg" val="' . $msg . '"/&gt;&lt;param var="location" val="London"/&gt;&lt;param var="apikey" val="9ee6ffd165r364492"/&gt;&lt;/params&gt;&lt;/method&gt;&lt;/methods&gt;&lt;/project&gt;');&lt;br /&gt;  $method_result = $xml_result-&gt;post2jaiku;&lt;br /&gt;  echo 'result' . $method_result;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Reference: &lt;a href="http://www.ibm.com/developerworks/library/x-simplexml.html"&gt;SimpleXML processing with PHP&lt;/a&gt; [ibm.com]</description>
      <pubDate>Wed, 19 Mar 2008 18:50:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5259</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Post to both Jaiku and Twitter</title>
      <link>http://snippets.dzone.com/posts/show/5247</link>
      <description>This XML code is the ProjectX API to post to both Twitter and Jaiku. This is a follow-up example from &lt;a href="http://snippets.dzone.com/posts/show/5239"&gt;Post to Jaiku using ProjectX API&lt;/a&gt; [dzone.com]&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;xml_project = &lt;&lt;PROJECT&lt;br /&gt;&lt;project name='micro_blog'&gt;&lt;br /&gt;  &lt;methods&gt;&lt;br /&gt;    &lt;method name='post2jaiku'&gt;&lt;br /&gt;      &lt;params&gt;&lt;br /&gt;        &lt;param var='user' val='YourJaikuUserName'/&gt;&lt;br /&gt;        &lt;param var='msg' val='YourMessage'/&gt;&lt;br /&gt;        &lt;param var='location' val='YourCity'/&gt;&lt;br /&gt;        &lt;param var='apikey' val='YourApiKey'/&gt;&lt;br /&gt;      &lt;/params&gt;&lt;br /&gt;    &lt;/method&gt;&lt;br /&gt;    &lt;method name='post2twitter'&gt;&lt;br /&gt;      &lt;params&gt;&lt;br /&gt;        &lt;param var='user' val='YourTwitterUserName'/&gt;&lt;br /&gt;        &lt;param var='msg' val='YourMessage'/&gt;&lt;br /&gt;        &lt;param var='password' val='YourPassword'/&gt;&lt;br /&gt;      &lt;/params&gt;&lt;br /&gt;    &lt;/method&gt;    &lt;br /&gt;  &lt;/methods&gt;&lt;br /&gt;&lt;/project&gt;"&lt;br /&gt;PROJECT&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 18 Mar 2008 15:36:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5247</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Post to Jaiku using ProjectX API</title>
      <link>http://snippets.dzone.com/posts/show/5239</link>
      <description>This Ruby code uses the ProjectX API on rorbuilder.info to send a post to Jaiku. &lt;br /&gt;&lt;br /&gt;Prerequisites:&lt;br /&gt;1) You have a Jaiku account. see http://jaiku.com/&lt;br /&gt;2) You know your Jaiku API key. see http://api.jaiku.com/&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;# file: projectx_client.rb&lt;br /&gt;&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;class ProjectXClient&lt;br /&gt;  attr :doc&lt;br /&gt;  def initialize(raw_url)&lt;br /&gt;    url = URI.escape(raw_url)&lt;br /&gt;    xml_data = Net::HTTP.get_response(URI.parse(url)).body&lt;br /&gt;    @doc = Document.new(xml_data)&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if __FILE__ == $0&lt;br /&gt;&lt;br /&gt;xml_project = &lt;&lt;PROJECT&lt;br /&gt;&lt;project name='jaiku'&gt;&lt;br /&gt;  &lt;methods&gt;&lt;br /&gt;    &lt;method name='post'&gt;&lt;br /&gt;      &lt;params&gt;&lt;br /&gt;        &lt;param var='user' val='YourJaikuUserName'/&gt;&lt;br /&gt;        &lt;param var='msg' val='YourMessage'/&gt;&lt;br /&gt;        &lt;param var='location' val='YourCity'/&gt;&lt;br /&gt;        &lt;param var='apikey' val='YourApiKey'/&gt;&lt;br /&gt;      &lt;/params&gt;&lt;br /&gt;    &lt;/method&gt;&lt;br /&gt;  &lt;/methods&gt;&lt;br /&gt;&lt;/project&gt;"&lt;br /&gt;PROJECT&lt;br /&gt;  &lt;br /&gt;  pxc = ProjectXClient.new("http://rorbuilder.info/api/projectx.cgi?xml_project=" + xml_project)&lt;br /&gt;  doc = pxc.doc&lt;br /&gt;  puts doc&lt;br /&gt;    &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You can also pass the url including xml into the address bar and it will post to Jaiku successfully.&lt;br /&gt;eg.&lt;br /&gt;http://rorbuilder.info/api/projectx.cgi?xml_project="&lt;project name='jaiku'&gt;&lt;methods&gt;&lt;method name='post'&gt;&lt;params&gt;&lt;param var='user' val='jrobertson'/&gt;&lt;param var='msg' val='testing 223'/&gt;&lt;param var='location' val='London'/&gt;&lt;param var='apikey' val='5ugr6ttr754y214445'/&gt;&lt;/params&gt;&lt;/method&gt;&lt;/methods&gt;&lt;/project&gt;"&lt;br /&gt;&lt;br /&gt;Note: &lt;br /&gt;Your api key is not in any way stored by the website rorbuilder.info.&lt;br /&gt;Rorbuilder.info is a 3rd party developer website which is not part of Jaiku.com.&lt;br /&gt;</description>
      <pubDate>Sun, 16 Mar 2008 21:33:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5239</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>jaiku.conf</title>
      <link>http://snippets.dzone.com/posts/show/4224</link>
      <description>// example configuration file for jaiku.py&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;config = "jaiku.conf"&lt;br /&gt;xmlrpcurl = "http://api.jaiku.com/xmlrpc"&lt;br /&gt;feedurlstart = "http://"&lt;br /&gt;feedurlend = ".jaiku.com/feed/atom"&lt;br /&gt;itemdelimeter = "&lt;entry&gt;"&lt;br /&gt;titledelimeter1 = "&lt;title&gt;"&lt;br /&gt;titledelimeter2 = "&lt;/title&gt;"&lt;br /&gt;username = "mcandre"&lt;br /&gt;personalkey = "FILL IN YOUR API KEY HERE"&lt;br /&gt;location = ""&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 29 Jun 2007 02:32:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4224</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>jaiku.py</title>
      <link>http://snippets.dzone.com/posts/show/4223</link>
      <description>// Set and view Jaiku statuses&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;__author__="Andrew Pennebaker (andrew.pennebaker@gmail.com)"&lt;br /&gt;__date__="28 Jun 2007"&lt;br /&gt;__copyright__="Copyright 2007 Andrew Pennebaker"&lt;br /&gt;__license__="GPL"&lt;br /&gt;__version__="0.0.1"&lt;br /&gt;__URL__="http://snippets.dzone.com/posts/show/4223"&lt;br /&gt;&lt;br /&gt;import sys, getopt, urllib2, xmlrpclib&lt;br /&gt;&lt;br /&gt;import configreader&lt;br /&gt;&lt;br /&gt;STATUS_MODE="STATUS"&lt;br /&gt;VIEW_MODE="VIEW"&lt;br /&gt;&lt;br /&gt;def set_status(settings, status):&lt;br /&gt;	s=xmlrpclib.ServerProxy(settings["xmlrpcurl"])&lt;br /&gt;	&lt;br /&gt;	calldata={"user":settings["username"], "personal_key":settings["personalkey"], "message":status, "location":settings["location"]}&lt;br /&gt;	&lt;br /&gt;	try:&lt;br /&gt;		s.presence.send(calldata)&lt;br /&gt;	except:&lt;br /&gt;		raise "Could not connect."&lt;br /&gt;&lt;br /&gt;def view_status(settings):&lt;br /&gt;	item=settings["itemdelimeter"]&lt;br /&gt;	t1=settings["titledelimeter1"]&lt;br /&gt;	t2=settings["titledelimeter2"]&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		instream=urllib2.urlopen(&lt;br /&gt;			settings["feedurlstart"]+settings["username"]+settings["feedurlend"]&lt;br /&gt;		)&lt;br /&gt;&lt;br /&gt;		for line in instream:&lt;br /&gt;			if item in line:&lt;br /&gt;				break&lt;br /&gt;&lt;br /&gt;		title=instream.readline()&lt;br /&gt;&lt;br /&gt;		instream.close()&lt;br /&gt;&lt;br /&gt;		status=title[title.index(t1)+len(t1):title.index(t2)]&lt;br /&gt;&lt;br /&gt;		return status&lt;br /&gt;&lt;br /&gt;	except IOError, e:&lt;br /&gt;		raise "Could not connect."&lt;br /&gt;&lt;br /&gt;def usage():&lt;br /&gt;	print "Usage: %s [options]" % (sys.argv[0])&lt;br /&gt;	print "\nWithout any options, uses status mode. Leftover args are concatenated to form message."&lt;br /&gt;	print "\n-u|--username &lt;username&gt; specified in jaiku.conf"&lt;br /&gt;	print "-p|--personal-key &lt;key&gt;"&lt;br /&gt;	print "-l|--location &lt;location&gt;"&lt;br /&gt;	print "-s|--status mode"&lt;br /&gt;	print "-v|--view status"&lt;br /&gt;	print "-c|--config &lt;configfile&gt;"&lt;br /&gt;	print "-h|--help"&lt;br /&gt;&lt;br /&gt;	sys.exit()&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;	global STATUS_MODE&lt;br /&gt;	global VIEW_MODE&lt;br /&gt;&lt;br /&gt;	systemArgs=sys.argv[1:]&lt;br /&gt;&lt;br /&gt;	mode=STATUS_MODE&lt;br /&gt;&lt;br /&gt;	settings={&lt;br /&gt;		"config":"jaiku.conf",&lt;br /&gt;		"xmlrpcurl":"http://api.jaiku.com/xmlrpc",&lt;br /&gt;		"feedurlstart":"http://",&lt;br /&gt;		"feedurlend":".jaiku.com/feed/atom",&lt;br /&gt;		"itemdelimeter":"&lt;entry&gt;",&lt;br /&gt;		"titledelimeter1":"&lt;title&gt;",&lt;br /&gt;		"titledelimeter2":"&lt;/title&gt;",&lt;br /&gt;		"username":"mcandre",&lt;br /&gt;		"personalkey":"",&lt;br /&gt;		"location":""&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	optlist, args=[], []&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		optlist, args=getopt.getopt(systemArgs, "u:p:l:svc:h", ["username=", "personal-key=", "location=", "status", "view", "config=", "help"])&lt;br /&gt;	except e:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-c" or option=="--config":&lt;br /&gt;			settings["config"]=value&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		configreader.load(open(settings["config"], "r"), settings)&lt;br /&gt;	except IOError, e:&lt;br /&gt;		pass&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-h" or option=="--help":&lt;br /&gt;			usage()&lt;br /&gt;&lt;br /&gt;		elif option=="-u" or option=="--username":&lt;br /&gt;			settings["username"]=value&lt;br /&gt;		elif option=="-p" or option=="--personal-key":&lt;br /&gt;			settings["personalkey"]=value&lt;br /&gt;		elif option=="-l" or option=="--location":&lt;br /&gt;			settings["location"]=value&lt;br /&gt;		elif option=="-s" or option=="--status":&lt;br /&gt;			mode=STATUS_MODE&lt;br /&gt;		elif option=="-v" or option=="--view":&lt;br /&gt;			mode=VIEW_MODE&lt;br /&gt;&lt;br /&gt;	if mode==STATUS_MODE:&lt;br /&gt;		if len(args)&lt;1:&lt;br /&gt;			usage()&lt;br /&gt;&lt;br /&gt;		message=" ".join(args)&lt;br /&gt;&lt;br /&gt;		set_status(settings, message)&lt;br /&gt;	elif mode==VIEW_MODE:&lt;br /&gt;		print view_status(settings)&lt;br /&gt;&lt;br /&gt;if __name__=="__main__":&lt;br /&gt;	try:&lt;br /&gt;		main()&lt;br /&gt;	except KeyboardInterrupt, e:&lt;br /&gt;		pass&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 29 Jun 2007 02:31:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4223</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
  </channel>
</rss>
