Skip to content

Instantly share code, notes, and snippets.

View soulfly's full-sized avatar

Mr. software craftsman soulfly

View GitHub Profile
QBAuth.createSession(new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
// result comes here
// check if result success
if (result.isSuccess()) {
// do stuff you need
}
}
});
/**
* Post message to Twitter
*/
private boolean postTwitt(UserAccountManager _userAccMan, String _message) {
try {
Tweet uT = new Tweet(_message);
TweetER tTR = TweetER.getInstance(_userAccMan);
tTR.post(uT);
return true;
} catch (IllegalArgumentException iAE) {
public class TwitterQBAuth implements QBHTTPAnswerListener
{
private String TOKEN = "";
private String timestamp = "";
private String BROWSER_SESSION = "";
private String TWITTER_AUTH_URL = "";
private final String QB_APP_ID = "341";
private final String QB_AUTH_KEY = "nhsOHKDNqwvpuDV";
private final String QB_AUTH_SECRET = "evPuQba3jC3Q6AX";
public class TwitterAuthScreen extends MainScreen implements Constants
{
private TwitterAuthScreen me;
private BrowserField browserField;
private ProtocolController protocolController;
private BrowserFieldErrorHandler browserFieldErrorHandler;
private BrowserFieldConfig browserFieldConfig = new BrowserFieldConfig();
private String twitterCookie = "";
private String twittwerAuthURL = "";
private TwitterPoster twitterPoster = null;
@soulfly
soulfly / QuickBlox signature generation example
Created December 12, 2012 13:28
QuickBlox signature generation example
// make query
long timestamp = System.currentTimeMillis()/1000;
int nonce = new Random().nextInt();
String signatureParams = String.format("application_id=%s&auth_key=%s&nonce=%s&timestamp=%s&user[login]=%s&user[password]=%s",
QBQueries.APPLICATION_ID, QBQueries.AUTH_KEY, nonce, timestamp, "test", "test");
String signature = null;
try {
signature = Signature.calculateHMAC_SHA(signatureParams, QBQueries.AUTH_SECRET);
} catch (SignatureException e) {
@soulfly
soulfly / Java HMAC_SHA1_ALGORITHM
Created December 12, 2012 13:25
Java HMAC_SHA1_ALGORITHM
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.SignatureException;
/**
* @author Igor Khomenko
* injoit.com
*
* This class defines common routines for generating
@soulfly
soulfly / gist:4153474
Created November 27, 2012 10:15
BlackBerry 5,6,7 Messages sample: Remove the notifications
try {
PushNotificationsStorage.getInstance().removePushNotification(pNO);
onClose();
} catch (Exception ex) {
System.out.println("removePushNotification exception = " + ex);
}
@soulfly
soulfly / gist:4153469
Created November 27, 2012 10:15
BlackBerry 5,6,7 Messages sample: Review the notifications
LabelField pushressievedLabel = new LabelField("Message ressieved on:") {
public void paint(Graphics g) {
g.setColor(0xffffff);
super.paint(g);
}
};
pushressievedLabel.setPadding(5, 5, 0, 5);
pushressievedLabel.setFont(pushressievedLabel.getFont().derive(Font.BOLD));
add(pushressievedLabel);
@soulfly
soulfly / gist:4153464
Created November 27, 2012 10:13
BlackBerry 5,6,7 Messages sample: Reception notifications (TURN OFF)
try {
System.out.println("----- Successfullly UNSUBSCRIBED FROM PUSH");
// Push Notification ON = 0
// Push Notification OFF = 1
OptionStorage.getInstance().getOption("Push notifications").setCurrentValueIndex(1);
} catch (Exception ex) {
DebugStorage.getInstance().Log(0, "<UnsubscribeQbPush> ProcessAnswer
REQUEST_PUSH_UNSUBSCRIBE ", ex);
}
break;
@soulfly
soulfly / gist:4153456
Created November 27, 2012 10:11
BlackBerry 5,6,7 Messages sample: Reception notifications (TURN ON)
try {
System.out.println("----- Successfully subsribed on Push notifications");
// Push Notification ON = 0
// Push Notification OFF = 1
OptionStorage.getInstance().getOption("Push notifications").setCurrentValueIndex(0);
} catch (Exception ex) {
DebugStorage.getInstance().Log(0, "<PushQbAuth> ProcessAnswer REQUEST_PUSH_SUBSCRIBE
Exception ", ex);
}
break;