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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 10
Registered: ‎04-05-2014
My Device: BB Alpha Device
My Carrier: Airtel

How to share data on Facebook and twitter

How to share data on Facebook and twitter. How their sdk we can implement
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to share data on Facebook and twitter

Have you searched this forum?  Try the search box you will find near the top right.

Developer
Posts: 40
Registered: ‎06-04-2014
My Device: Bold 9900

Re: How to share data on Facebook and twitter

[ Edited ]

Hi, I just recently worked on pulling statuses from Facebook. Here's what I did:

 

Make an HTTP connection to the public Facebook feed. You can grab a public feed by using a url similar to   

 

https://www.facebook.com/feeds/page.php?id=<feed id here>&format=json


Once you've made the connection, make sure you parse the return string as UTF-8:

 

byte[] bytes = IOUtilities.streamToBytes(conn.openInputStream());
StringBuffer buff = new StringBuffer(new String(bytes, "UTF-8"));

 

One you've parsed the data as UTF-8 you can do something similar to the below code:

 

root = new JSONObject(output);
						
						
JSONArray entries = root.getJSONArray("entries");
						
JSONObject entry_obj1 = entries.getJSONObject(0);
JSONObject entry_obj2 = entries.getJSONObject(1);
JSONObject entry_obj3 = entries.getJSONObject(2);
						
String entry1 = TextUtils.unescapeHTML(entry_obj1.getString("title").trim(),0);
String entry2 = TextUtils.unescapeHTML(entry_obj2.getString("title").trim(),0);
String entry3 = TextUtils.unescapeHTML(entry_obj3.getString("title").trim(),0);

 


In that code, I'm grabbing the array of entries from the JSON structure, and then grabbing the titles of the last 3 posts.

 

 As far as Twitter goes, I actually gave up once I found out that you need to be authenticated in order to use their API. I couldn't get a twitter sdk for Java imported into Blackberry correctly so I gave up.