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
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

How to parse a response ??

If i operate with these url,  then how can I get the real values..
How to parse response..
Please please help me
Please use plain text.
Developer
Developer
arv
Posts: 122
Registered: ‎08-11-2008
My Device: 9700
My Carrier: XL

Re: How to parse a response ??

 

Hi 

 

 

 

--
"Give kudos (star) if you feel response is helpful"
Please use plain text.
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

Re: How to parse a response ??

 

  String accessTo= pfbc.getApplicationSettings().accessToken;
     suppose accessTo == xxyyzzz
          String url2 = "https://graph.facebook.com/me/home?access_token=xxyyzz";
          try 
        {
            StringBuffer response2 = (fbc.getHttpClient()).doGet(url2);
            byte[] data2 = response2.toString().getBytes();
            String value2 = new String(data2);
 System.out.println("*****  "+value2);

 

          }

catch(Exception){}

 

 

  Output: ***** {"data":[]}

 

this link is for retrieving news feed. But I am getting {"data":[]}

 

how can I retrieve the news feed from this response ?

 

EX.


String url = "http://graph.facebook.com/"+me.getId()+"/picture?type=square";

I do:

 

try {
        StringBuffer response = (fbc.getHttpClient()).doGet(url);
        byte[] data = response.toString().getBytes();
        if (data.length > 0) {
             mybitmap = Bitmap.createBitmapFromBytes(data, 0, data.length, 1);
            }
        }
        catch(Exception ep){System.out.println("Exception in retrieving My pic");}

 

BitmapField mypicture = new BitmapField (mybitmap );

add(mypicture);

 

Output:

I am getting my facebook picture...

 

 

But I can not handle https://graph.facebook.com/me/home?access_token=xxyyzz";

Please use plain text.
Developer
Developer
arv
Posts: 122
Registered: ‎08-11-2008
My Device: 9700
My Carrier: XL

Re: How to parse a response ??

 

First: (the News feed).

 

I think there's a problem with your access token,

try it first the complete URL on the computer browser?

if you retrieve the same empty response,

then maybe something error with the access_token.

 

I saw the URL is correct: https://graph.facebook.com/me/home?access_token=xxx

 

 

try it first,

then inform again here.

 

 

--
"Give kudos (star) if you feel response is helpful"
Please use plain text.
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

Re: How to parse a response ??

I test it in the computer browser.

You might be right. I am not getting the correct access_token.

 

But one thing happens today :

When i use this link :  https://graph.facebook.com/me/home?access_token=xxx...

I got something like this ::

 

 

{"data":[{"caption":"www.youtube.com","updated_time":"2011-01-25T19:27:40+0000","from":{"id":"100000691000885","name":"Sarwesh Kumar"},"created_time":"2011-01-25T19:27:40+0000","link":"http://www.youtube.com/watch?v=qEKw0KYOHy8","type":"video","icon":"http://static.ak.fbcdn.net/rsrc.php/yj/r/v2OnaTyTQZE.gif","picture":"http://external.ak.fbcdn.net/safe_image.php?d=d827f45cca384ea04560c39a502f1812&w=130&h=130&url=http%...","id":"100000691000885_188869577797494","name":"Rashtrageet","source":"http://www.youtube.com/v/qEKw0KYOHy8&autoplay=1"}],"paging":{"previous":"https://graph.facebook.com/me/home?access_token=317175255300%7C2ae4a8c067fabe709441b215-100000512262...","next":"https://graph.facebook.com/me/home?access_token=317175255300%7C2ae4a8c067fabe709441b215-100000512262..."}}

 

{"data":[{"caption":"www.youtube.com","updated_time":"2011-01-25T19:27:40+0000","from":{"id":"100000691000885","name":"Sarwesh Kumar"},"created_time":"2011-01-25T19:27:40+0000","link":"hfhfghfh","type":"video","icon":"http://static.ak.fbcdn.net/rsrc.php/yj/r/v2OnaTyTQZE.gif","picture":"http://external.ak.fbcdn.net/safe_image.php?d=d827f45cca384ea04560c39a502f1812&w=130&h=130&url=http%...","id":"100000691000885_188869577797494","name":"Rashtrageet","source":"http://www.youtube.com/v/qEKw0KYOHy8&autoplay=1"}],"paging":{"previous":"https://graph.facebook.com/me/home?access_token=xxytyr...","next":"https://graph.facebook.com/me/home?access_token=dsfsdg.."}}

 

So i thought that my access_token is correct.

 

But when i use this link :https://graph.facebook.com/?ids=12345678754&access_token=xxyyzz..

using same access_token ...

I am not getting the full information about the user.

 

I use this link in computer browser :

 

https://graph.facebook.com/?ids=685104253&access_token=2227470867|2.YEnZgZHp__obkPZhPfD_Hw__.3600.12...

 

I got the whole information about a user having 685104253 id.

 

But after sometime I don't get the same, though i use the same link.


Please see the images 

 

 

hdjg.PNG

 

 

hdjg.PNG

 

What should I do?

 

Please use plain text.
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

Re: How to parse a response ??

me.PNG

Please use plain text.
Developer
lyt0101
Posts: 28
Registered: ‎10-30-2010
My Device: Torch 9800

Re: How to parse a response ??

I think the SDK actually does that for you already. Check out the strawberry sample that comes with the SDK

 

calling user.getFriends() will return you a list of friends as User objects and user.getStream() gives you an array of Post objects, or you can pass in the number of posts you want as parameter

 

Or if you choose to do it by yourself, the json package that comes with the source code should give you some clue how to do the parsing

 

Please use plain text.
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

Re: How to parse a response ??

I am using the Strawberry sample. But they are only providing the name, last name first name, gender, time zone etc

 

But they are not giving the whole information.

 

How to get that.?

Please use plain text.
Developer
lyt0101
Posts: 28
Registered: ‎10-30-2010
My Device: Torch 9800

Re: How to parse a response ??

What do you mean by whole information? Can you specify what information you want to retrieve?

Please use plain text.