Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 83
Registered: ‎05-24-2011
My Device: Storm 9550

Twitter / Facebook integration with oauth

Hi all,

 

We are attempting to take our app to the next level, and integrate social media in our application. I have been trying to work through (without much succes) the Strawberry example for Facebook. If anyone is familiar with the these API's, I am having trouble setting who the user is. Has anyone successfully used this?

 

Also, I am running into loads of trouble with Twitter. It seems that the method of authentication has recently changed to use OAuth. My question is, will the xAuth methods still work? If not, are there any examples of working code? Here is what I am trying to use:

 

HttpRequest req = new HttpRequest("https://api.twitter.com/oauth/access_token");
				req.setMethod(HttpConnection.POST);
				XAuthSigner signer = new XAuthSigner(consumerKey, consumerSecret);
				signer.signForAccessToken(req, "355519342-fsGbRIfcPT4O3eICM9JKDGE9OONxC6cst1VCQOea", "22y9KZE4SmY342rVAWWAQrCIeO04R4KMTY5701up0");//HERE I'M SUPPOSED TO PUT A USER/PASS COMBO
				try {
				HttpResponse resp = req.send();
				if (resp.getCode() == HttpConnection.HTTP_OK) {
				Token accessToken = Token.parse(resp.getBodyContent());

				req.close();

				req = new HttpRequest("http://api.twitter.com/1/statuses/update.xml");
								          req.setMethod(HttpConnection.POST);
								          req.setBodyParameter("status", "Just used my BB ");          req.setSigner(signer, accessToken);
				resp = req.send();
				   }
				} catch (IOException e) {
				e.printStackTrace();
				} finally {
				try {
				req.close();
				} catch (IOException e) {}
				}

 

Thanks!

Regular Contributor
Posts: 83
Registered: ‎05-24-2011
My Device: Storm 9550

Re: Twitter / Facebook integration with oauth

Ok so it turns out I got Facebook working fine once I downloaded the new Sdk(since I'm writing for v5.0 os), however, I am still having trouble with Twitter.

 

In this line of code:

signer.signForAccessToken(req, "355519342-fsGbRIfcPT4O3eICM9JKDGE9OONxC6cst1VCQOea", "22y9KZE4SmY342rVAWWAQrCIeO04R4KMTY5701up0")

 I tried just putting in my username and password and nothing happens...There are no errors, and when I run the debugger line by line, every line of code gets used...any ideas?