Sample Facebook classes for c#? - json

Like some of you allready know, i'm trying to get data from facebook in JSON format and view it in a gridview or something like that.
With some help of StackOverflow, i managed to get the data i needed.
Now I want to make a List of my json string.
Do I have to make a class for every JSON object in my json string? Like the class user, location, work_info, education_info?
Is there any place where i can find the c# class files for all the facebook objects?
I think there are a lot of programers who use these classes, does everyone write the same classes again?
I have added a reference to the facebook(.web) sdk. But I don't know if I can use this for my problem.
I hope you can help me,
Thx!

The reason why there are not strongly typed classes for Facebook Schema in the Facebook C# SDK is that they usually change very frecuently. That's why the developers of the Facebook C# SDK decided not to go that way:
http://ntotten.com/2010/08/dynamic-csharp-with-frequently-changing-web-services/
http://ntotten.com/2010/09/dynamic-objects-and-the-facebook-c-sdk/
Although if read the Roadmap: http://facebooksdk.codeplex.com/wikipage?title=Road%20Map you will see that there are plans for a strongly typed Graph API objects but it looks like there is no much activity in that area.
If you need strongly typed classes for your app, you will probably only use a few that are easy to create.

Related

JSON response object more organized

My question might seem silly but for example:
I want to get all the movies from 'The Movie DB'; they provided me with the api_key and a link, i.e: http://api.themoviedb.org/3/movie/popular?api_key="my_api". When I pass this link into firefox / chrome ( with my api instead of "my_api" ) I get a bunch of JSON objects and I can't really distinguish them.
Is there any way that I can organize the JSON object in something more readable in the sense of organized?
I get this but I want it organized
Any idea?
Firefox has a JSON viewer as you describe built in. Are you using a current version? See: https://developer.mozilla.org/en-US/docs/Tools/JSON_viewer
There are plugins for other browsers. For example for Chrome look at https://chrome.google.com/webstore/search/json

where can i get fake JSON of store so i can practice fetch data?

Is their any site where i can get fake JSON which have array of object related to store that include image price name so that I can improve my skill related to JSON GET,POST?
please any one suggest me site other then fake JSON placeholder
Thanks in advance
I used JSON BLOB to store JSON and creating links like APIs to teach my students.
Follow the steps to create JSON and get it over URL:
Create JSON into the editor
Click on the save button in the header.
You will get a link something like, https://jsonblob.com/e29c9fd2-13be-11e9-aac5-659aad2453a7
In the link replace https://jsonblob.com/ to https://jsonblob.com/api, in my case the new link will be https://jsonblob.com/api/e29c9fd2-13be-11e9-aac5-659aad2453a7
That's it! It will work like an API.
I recommend you to please once try fake-store-api .I have personally used this in my e-commerce projects.

Snake case json when using default Grails JSON renderer

I am building an app with Groovy/Grails (long-time Java developer), and have had some difficulty with making the JSON renderer do what I want. I would like to change the default name rendering scheme to snake case instead of camel case.
The controller code is very simple right now:
Fund show(String id) {
respond fundService.getFund(id)
}
With Java I would use Jackson and a custom naming strategy, like so:
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
Any help would be appreciated! If there is no way of doing this, and I just need to switch out the renderer wholesale, I would welcome knowing that as well. Thank you.
Create a custom marshaller - you can control anything from there
see here how to create one:
http://compiledammit.com/2012/08/16/custom-json-marshalling-in-grails-done-right/

Is it possible to parse a Google+ (Google Plus) profile page?

If you view the source of a Google+ profile page, it appears rather complex. It seems most of the data is kept in a huge JSON-like objects. However, they don't seem to be really JSON, since they don't get recognized when I try to decode them. I am hoping the format is more clear to other people here. How would you go about parsing it? It seems it would fairly trivial, if you know where to start.
Here is a sample profile, for example: http://plus.google.com/104560124403688998123
Here's a PHP API I'm working on. It can download and parse the data for a profile page and people's public relationships.
https://github.com/jmstriegel/php.googleplusapi
The JSON piece is a bit mangled. To generate valid JSON, you basically have to remove the first 5 characters that prevent XSRF attacks and then add in all the nulls that have been removed. Here's the code specific to handling parsing the weird Google Plus JSON responses:
https://github.com/jmstriegel/php.googleplusapi/blob/master/lib/GooglePlus/GoogleUtil.php
Call GoogleUtil::FetchGoogleJSON( $url ) and you'll get back a giant array that you can then pull data from. Using this, it should be trivial to make a proxy service to translate stuff into valid json(p) for you to use in your own apps.
I don't have access to Google+ yet, so I'll just answer the general question - that is, how to parse JSON.
JSON is just JavaScript, so parsing it is as simple as evaluating the script. To do this, use the eval() JavaScript function.
var obj = eval('{"JSON":"goes here"}');
Another option is to leverage a console tool. Popular modern browsers pretty much all have them. I recommend Firebug for Firefox in particular.
Using Firefox, log into Google+, then open the Firebug console. You can use the console's dir() command to create a browseable representation of the data. Ex:
console.dir(eval('{"JSON":"goes here"}'));
Sorry I can't be more specific about how to get a handle on Google+'s JSON in particular; without access to the service, this is about the best I can do blind. Good luck!
Thanks to Jason for the excellent php class which reads a profile page into an array.
I've used this class as a base and then parsed it, based upon Russell Beattie's python code from the original appspot rss feed application.
Code here
A few notes:
I use this to merge G+ and WP feeds, hence writing posts into an intermediate array ($items).
I have a convention of creating a pseudo title in Google Plus posts, by emboldening a line and adding two newlines before writing the post. The function getTitle strips this out as a better formatted title in my website and getSummary produces the rest of the post with duplicating the title.
It's made up of a number of parts, an object describing your picasa images, one describing the fields on your profile, one describing your friends.
Most of the long numbers are the internal IDs of people, posts and photos. For instance, my ID is 105249724614922381234. Other than that, it could be parsed if you needed to.

Facebook Event Json Mesage- how can i get it?

I would like to ask if someone know how to grab a facebook event json message. It doesnt matter if it has to happen programatically. I just want to be able to read the message one way or another.
thanks in advance.
P.s. Maybe an awful question but here you go !!!
I once had to code a small chunk of code to parse a json-encapsulated message. However recently I found out there's a handy solution for it if you use Java
Resty is a small, convenient library
to talk to RESTful services from Java.
It’s surprisingly complex to do the
simplest HTTP calls with the standard
Java library. Resty hopes to change
that.
http://beders.github.com/Resty/Resty/Overview.html
Resty r = new Resty();
Object name = r.json("http://ws.geonames.org
/postalCodeLookupJSON?postalcode=66780&country=DE")
.get("postalcodes[0].placeName");
Just import a small jar lib and you'll be surprised. I currently use this class for getting info from url API.