Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Created September 16, 2011 18:47
Show Gist options
  • Save qrtt1/1222795 to your computer and use it in GitHub Desktop.
Save qrtt1/1222795 to your computer and use it in GitHub Desktop.
jPlurk_OAuth example
package com.google.jplurk_oauth.example;
import java.util.Properties;
import com.google.jplurk_oauth.Qualifier;
import com.google.jplurk_oauth.module.Timeline;
import com.google.jplurk_oauth.skeleton.PlurkOAuth;
import com.google.jplurk_oauth.skeleton.RequestException;
public class Example {
public static void main(String[] args) throws RequestException {
Properties prop = System.getProperties();
/* create oauth config */
PlurkOAuth auth = new PlurkOAuth(
prop.getProperty("appkey"), prop.getProperty("appsecret"),
prop.getProperty("token"), prop.getProperty("tokensecret"));
auth.using(Timeline.class).plurkAdd("Hello JPlurk-OAuth", Qualifier.SAYS);
}
}
package com.google.jplurk_oauth;
import org.json.JSONObject;
import com.google.jplurk_oauth.module.AbstractModule;
import com.google.jplurk_oauth.module.Args;
import com.google.jplurk_oauth.module.HttpMethod;
import com.google.jplurk_oauth.module.RequestException;
public class Polling extends AbstractModule {
public JSONObject getPlurks(Offset offset) throws RequestException
{
Args args = new Args().add("offset", offset.formatted());
return requestBy("getPlurks").with(args).in(HttpMethod.GET).thenJsonObject();
}
public JSONObject getUnreadCount() throws RequestException {
return requestBy("getUnreadCount").withoutArgs().in(HttpMethod.GET).thenJsonObject();
}
@Override
public String getModulePath() {
return "/APP/Polling";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment