function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PSahuPSahu 

How to get Json data and apend in div by hit a api

For example if i want to get news feed from facebook by graph api and apend these JSON data feed into the div by visualforce pages then how is it possible please explain the procedure i am new in salesforce and apex

I am done this task in php demo link :- http://joomla25.webkul.com/facebook-display/facebook-wall-feed.html

We want make a aap in salesforce like this.
Shrikant BagalShrikant Bagal
Hello Ayush,

Can you share the Sample JSON Data?

Thansk!
PSahuPSahu
After hit this link CAAGIV8ndRDcBALpKhd5t5smOzFMv25HLpgqMqfZBhwZCJMbqPFW4aOZCXphud9tc7w9EEw0vBvRooZB7idLHLK3LkzS0pQP63pysUUZA7We5EV8IqZAsj7WwEhXf97C34aDKyaKW8lyvihyxl2duEpMjuHGs7LlsyPEZAwSJjykSpomgALOdvZBV

you will get the data
PSahuPSahu
sorry correct link is this:_ https://graph.facebook.com/webkul?access_token=CAAGIV8ndRDcBALpKhd5t5smOzFMv25HLpgqMqfZBhwZCJMbqPFW4aOZCXphud9tc7w9EEw0vBvRooZB7idLHLK3LkzS0pQP63pysUUZA7We5EV8IqZAsj7WwEhXf97C34aDKyaKW8lyvihyxl2duEpMjuHGs7LlsyPEZAwSJjykSpomgALOdvZBV
PSahuPSahu
Any Updates?
PSahuPSahu
???
Aditya TopalliAditya Topalli
First,

You have to make a HTTP Callout to the URL

Http http =new Http();
HttpRequest req =new HttpRequest();
req.setEndpoint('URL');
req.setmethod('POST');
HttpResponse res = http1.send(req);
String str = res.getbody();

Make sure you add 'https://graph.facebook.com' to Remote Site Settings to whitelist the URL.

String str contains the JSON Response from the Callout. Refer the below url for tips on parsing in Apex:
http://blog.adityanaag.com/22/Parsing+JSON+the+easy+way+using+Apex

Format the response to the HTML Div Structure you want to, and then rerender the div, or use oncomplete Javscript to append.

 
PSahuPSahu
Awesome Answer :) by Aditya Topalli
But when we try by this url
https://graph.facebook.com/1632561326962584/feed?subscriptions&limit=5&locale=en_GB&access_token=CAAUamahUQOsBAKS9NWrCem32hTCZBo9hkjcphIIOmbykJXxEmkSQF38Xngoxrc6NZCT3AGTpqLWzMbmP1MWMXgmWOjCvQIAcG4gRHtNFKmOQ40iefYpiHK59KzvSNwcB9ZBXesSPFEoUfc35BbpuT7KrwJreEGrUZBmgRC1uAd1Llpd4ZA49fs3jDV7znaZBkWurRYsozX3L8rDzurB6dr

there is a issue with parse this after parsing this we get this reponse

JSON2Apex:[data=(Data:[actions=(Actions:[link=https://www.facebook.com/1632561326962584/posts/1663155387236511, name=Comment], Actions:[link=https://www.facebook.com/1632561326962584/posts/1663155387236511, name=Like], Actions:[link=https://www.facebook.com/1632561326962584/posts/1663155387236511, name=Share]), application=Application:[category=Business, id=562782210527561, link=http://himanshudangwal.com/wordpress/, name=him_test_app], caption=himanshudangwal.com, created_time=2015-07-09T14:17:56+0000, description=null, icon=https://www.facebook.com/images/icons/post.gif, id=1632561326962584_1663155387236511, is_expired=false, is_hidden=false, link=http://himanshudangwal.com/wordpress/, message=hwregdsfdsf, name=himanshudangwal.com, object_id=null, picture=null, privacy=Privacy:[allow=, deny=, description=Public, friends=, value=EVERYONE], properties=null, status_type=shared_story, story=null, story_tags=null, subscribed=true, type=link, updated_time=2015-07-09T14:17:56+0000], Data:[actions=(Actions:[link=https://www.facebook.com/1632561326962584/posts/1660390110846372, name=Comment], Actions:[link=https://www.facebook.com/1632561326962584/posts/1660390110846372, name=Like], Actions:[link=https://www.facebook.com/1632561326962584/posts/1660390110846372, name=Share]), application=null, caption=webkul.com, created_time=2015-07-01T13:36:35+0000, description=Enthusiastic about innovating new ideas and implementing them. Though a slow learner but always open to learn new things and face challenges., icon=https://www.facebook.com/images/icons/post.gif, id=1632561326962584_1660390110846372, is_expired=false, is_hidden=false, link=http://webkul.com/blog/author/anant158/, message=null, name=Anant Garg, object_id=null, picture=https://fbexternal-a.akamaihd.net/safe_image.php?d=AQDXKCcCvsJWv330&w=100&h=100&url=http%3A%2F%2Fwebkul.com%2Fblog%2Fwp-content%2Fuploads%2F2015%2F06%2FPhoto0039.jpg&cfs=1&sx=0&sy=0&sw=100&sh=100, privacy=Privacy:[allow=, deny=, description=Public, friends=, value=EVERYONE], properties=null, status_type=shared_story, story=Praku Sahu shared a link., story_tags=Story_tags:[], subscribed=true, type=link, updated_time=2015-07-01T13:36:35+0000], Data:[actions=(Actions:[link=https://www.facebook.com/1632561326962584/posts/1657498361135547, name=Comment], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657498361135547, name=Like], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657498361135547, name=Share]), application=null, caption=null, created_time=2015-06-23T09:19:22+0000, description=https://store.webkul.com . WebKul Store is the largest collection of open source plugins , we build best marketplace and openERP connectors in the world ., icon=https://www.facebook.com/images/icons/post.gif, id=1632561326962584_1657498361135547, is_expired=false, is_hidden=false, link=https://www.facebook.com/webkul, message=testing, name=WebKul, object_id=285021323071, picture=https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/v/t1.0-1/p200x200/11082497_10153365449148072_9014439846331811443_n.png?oh=adb701df74f97ee51aed601f6d7b8dc2&oe=5620B559&__gda__=1448513420_ea7eba8660da12fa690e08b0a20d2cd7, privacy=Privacy:[allow=, deny=, description=Public, friends=, value=EVERYONE], properties=(Properties:[name=Software, text=7,095 like this]), status_type=shared_story, story=null, story_tags=null, subscribed=true, type=link, updated_time=2015-06-23T09:19:22+0000], Data:[actions=(Actions:[link=https://www.facebook.com/1632561326962584/posts/1657495714469145, name=Comment], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657495714469145, name=Like], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657495714469145, name=Share]), application=null, caption=null, created_time=2015-06-23T09:02:45+0000, description=https://store.webkul.com . WebKul Store is the largest collection of open source plugins , we build best marketplace and openERP connectors in the world ., icon=https://www.facebook.com/images/icons/post.gif, id=1632561326962584_1657495714469145, is_expired=false, is_hidden=false, link=https://www.facebook.com/webkul, message=Hello this is Facebook Like promotion test, name=WebKul, object_id=285021323071, picture=https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/v/t1.0-1/p200x200/11082497_10153365449148072_9014439846331811443_n.png?oh=adb701df74f97ee51aed601f6d7b8dc2&oe=5620B559&__gda__=1448513420_ea7eba8660da12fa690e08b0a20d2cd7, privacy=Privacy:[allow=, deny=, description=Public, friends=, value=EVERYONE], properties=(Properties:[name=Software, text=7,095 like this]), status_type=shared_story, story=null, story_tags=null, subscribed=true, type=link, updated_time=2015-06-23T09:02:45+0000], Data:[actions=(Actions:[link=https://www.facebook.com/1632561326962584/posts/1657145401170843, name=Comment], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657145401170843, name=Like], Actions:[link=https://www.facebook.com/1632561326962584/posts/1657145401170843, name=Share]), application=null, caption=null, created_time=2015-06-22T08:47:56+0000, description=null, icon=https://www.facebook.com/images/icons/photo.gif, id=1632561326962584_1657145401170843, is_expired=false, is_hidden=false, link=https://www.facebook.com/photo.php?fbid=1657145401170843&set=a.1421483561403696.1073741828.100006261968588&type=1, message=amazing, name=null, object_id=1657145401170843, picture=https://scontent.xx.fbcdn.net/hphotos-xpa1/v/l/t1.0-9/s130x130/11540923_1657145401170843_1095809081093448706_n.jpg?oh=6acc34ac4e0fa4db0d63d98c59000c79&oe=5617B772, privacy=Privacy:[allow=, deny=, description=Public, friends=, value=EVERYONE], properties=null, status_type=added_photos, story=null, story_tags=null, subscribed=true, type=photo, updated_time=2015-06-22T08:47:56+0000]), paging=Paging:[next=https://graph.facebook.com/v2.3/1632561326962584/feed?limit=5&locale=en_GB&access_token=CAAUamahUQOsBAKS9NWrCem32hTCZBo9hkjcphIIOmbykJXxEmkSQF38Xngoxrc6NZCT3AGTpqLWzMbmP1MWMXgmWOjCvQIAcG4gRHtNFKmOQ40iefYpiHK59KzvSNwcB9ZBXesSPFEoUfc35BbpuT7KrwJreEGrUZBmgRC1uAd1Llpd4ZA49fs3jDV7znaZBkWurRYsozX3L8rDzurB6dr&until=1434962876&__paging_token=enc_AdCDUVJNi4pQwi3Fd6w1Lyem8w4AP3q07IRGDVyIHhDWOTajSNejdRXCzu17j6zXrk1AUZCnZCCteRnFq8xPfFJHuvofMAtzZCaWkXEw3GiA3bkcwZDZD, previous=https://graph.facebook.com/v2.3/1632561326962584/feed?limit=5&locale=en_GB&since=1436451476&access_token=CAAUamahUQOsBAKS9NWrCem32hTCZBo9hkjcphIIOmbykJXxEmkSQF38Xngoxrc6NZCT3AGTpqLWzMbmP1MWMXgmWOjCvQIAcG4gRHtNFKmOQ40iefYpiHK59KzvSNwcB9ZBXesSPFEoUfc35BbpuT7KrwJreEGrUZBmgRC1uAd1Llpd4ZA49fs3jDV7znaZBkWurRYsozX3L8rDzurB6dr&__paging_token=enc_AdDaez7ZBZA3dfZCZBnB9t6MU0rlklCSNbmKWxVHXUZCvDJmlqmwx5xr7sZBvlK8CaDkQcZCwBRkiXuBHyNkxPmDZAUV71adRzaDyOiVMcChsiaHZAZAyimAZDZD&__previous=1]]

Please check it and help in that and also provide any example how to append this parse data to vf pages our goal is to make this type of app demo is here :- http://cs-cartdemo.webkul.com/addonsdemo/facebook-wall-feed