![]() |
|
[.NET] Facebook API - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Facebook API (/showthread.php?tid=4372287) |
Facebook API - SIM-1456245 - Aug 1, 2014 So I saw that simplistic Facebook API by GammaRay, and thought I'd recode it in a proper way. So here it is, it uses proper JSON deserialization and it uses threads and events, so your application won't hang. It has also no memory leaks. This API class will allow you to get persons info from Facebook with ease. It will return the following info:
You just need to call the FetchData method with the persons username as parameter and after all of the data is parsed, the completed event will be raised with the data in the event args. In case an error occurs, the Error event is risen with the exception as argument. Everything is disposed properly, so you won't have problems with that. And it is multi-threaded, so your app won't hang. And this uses proper JSON deserialization. So you will need to add reference to System.Web.Extensions. Enough talking here is the code: http://pastebin.com/q5t3mhZa Example usage: http://pastebin.com/bU05x7FV Note: The Picture URL parsing is a bit messy, but I was too lazy to make it look nicer. * - Washi - Aug 1, 2014 Not trying to be rude or anything, but I wouldn't call this that "proper" as you claim it to be actually. So many try catch statements o_O. There is really no point in using so many and to raise in every catch handler the error event. That is like reinventing the try statement, which is pretty useless. Why wrapping the code of the FetchData and DeserializeData methods? You must be quite paranoid for errors lol. ConvertImage is rather a strange name to be honest for what it is doing. But that might be just my opinion. Moreover you are not passing the errors provided in the DownloadStringCompletedEventArgs to the end user, which could lead to getting no response at all without knowing what the cause is. No need for assigning the picJSON and picURL to Nothing. They will get assigned by the TryGetValue method. I take this back, seems it is needed in vb but not in c#. Also why recreating a serializer over and over again? Why not just have one instance of it and reuse it? * - Nervo - Aug 1, 2014 This might come in handy lel. Nice work and thanks for the nice contribution. @TheUnknownProgrammer he is maybe still learning, go easy with him :) * - SIM-1456245 - Aug 1, 2014 (Aug 1, 2014 04:02 PM)TheUnknownProgrammer Wrote: Not trying to be rude or anything, but I wouldn't call this that "proper" as you claim it to be actually. Hehe, complains about my error handling method as always. I know that you don't like it, but I do, so I use it. Some people call it "the usual error event" in my sources. That is how I like it man. And for that serializer, I for some reason had it as a private object in my class and moved it there. My bad. And for the error event, if you want, I can remove it from the code, but in my projects, I use it. Didn't want to be rude, removed the error event. * - Washi - Aug 1, 2014 (Aug 1, 2014 04:26 PM)Electroalek Wrote: Hehe, complains about my error handling method as always. I know that you don't like it, but I do, so I use it. Some people call it "the usual error event" in my sources. That is how I like it man. And for that serializer, I for some reason had it as a private object in my class and moved it there. My bad. And for the error event, if you want, I can remove it from the code, but in my projects, I use it. Lol you didn't have to remove it entirely. You were just using it too often. * - Mommy - Aug 1, 2014 Well what would be the point of using this? For like doxing and shizz? * - SIM-1456245 - Aug 1, 2014 (Aug 1, 2014 04:31 PM)Mommy Wrote: Well what would be the point of using this? For like doxing and shizz? To be honest, I don't know either, I just coded this because of the other version coded by GammaRay. * - GammaRay - Aug 1, 2014 I initially made it while I was making a small facebook client for myself. Some people have their ideas and will use it for that. * - insp3ctor - Aug 1, 2014 I know how to use it! :D Thank you for release finally i made it working after like idk 5 or 6 hours examinating and deleting random lines in code :D finally i made it working without understanding almost anything about functions just one question : is it possible to make profile picture bigger? because im getting really low resolution image in my picture box and after stretching it looks bad i think it should be possible to get higher resolution picture? |