0

I am fetching friends of the logged in users on my website from facebook in the JsonObject in [name,uid] pair .

I have attached the debug image of the object.

enter image description here

I am referring to this code for reference

JSONObject me = api.Get("/me"); JSONObject meFriends = api.Get("/me/friends");

How do i store extract and store the id and name of meFriends?

I want to store this name value pair in sql database?

Please help how could i achieve this?

1 Answer 1

2
  1. Change JSONObject meFriends = api.Get("/me/friends"); to JSONObject meFriends = api.Get("/me/friends?fields=id,name");
  2. foreach thru the resulting data in meFriends and inside of it you will do steps 3-5
  3. create a parameters array
  4. assign the id and name from data
  5. call insert sproc passing it the parameters array

Of course, I'd recommend you look into batch operations relating to your particular data adapter rather than killing your data store with umpteem-zillion calls, but I wanted the pseudo-code to be clear.

Depending upon the data store and the data adapter you use, they may already have ways to store arrays of objects without having to do what I showed above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.