4

I wish to access the FaceBook Ads API using the FaceBook toolkit for .NET (which i found in codeplex.com)

Wish to access the ads.estimateTargetingStats in particular .

details of FaceBook Ads API

FaceBook Ads API reference

Are there any frameworks(in .NET) developed around the FaceBook APIs . I am aware of

  1. FaceBook Toolkit ,
  2. FaceBook .NET

both are from codeplex.

Does someone let me know how to achieve the above quoted requirement with any .NET framework ?

demonplus
  • 5,613
  • 12
  • 49
  • 68
vijaysylvester
  • 4,750
  • 7
  • 29
  • 41

2 Answers2

3

Update: As stated on the repository, the project is no longer being maintained.


For those still looking for an answer, I recently released an unofficial SDK for C#. The code is available on GitHub here.

It implements most of the GET requests that are available by acting as a wrapper for the Facebook SDK for C#. Hope it helps anyone at all.

Paradoxis
  • 4,471
  • 7
  • 32
  • 66
  • this looks great but your documentation is incredibly confusing. can you make it clearer the hierarchy needed for the different files – Simon_Weaver Jul 12 '16 at 01:57
  • @Simon_Weaver what would you like me to write docs on? I write the library to use the same class structure as the official PHP library does to make it a little more easy on another developer to use it (I also have an example of it on [my Github Gist profile](https://gist.github.com/Paradoxis/b4a9e540adfbc80604832d922d2f2957)) – Paradoxis Jul 12 '16 at 07:31
  • Thank you for your reply. What was confusing me was the directory structure needed to run the generator. Eg. Do I copy src or the contents of src. – Simon_Weaver Jul 12 '16 at 07:38
  • Then I realized you had a complete set of generated classes already so I was able to use those. However I couldn't find a way to load the information for a single ad if I knew its id. Is this possible? I could do new Ad("12345") but how would I get the properties of the ad itself (child properties works but how could I get ad.name if I only had the ad id) thanks! – Simon_Weaver Jul 12 '16 at 07:41
  • @Simon_Weaver you don't necessarily have to run the generator unless you want to update all of the classes, all of them are in the `FacebookAds.Object` and `FacebookAds.Object.Fields` namespaces. However if you still want to run the generator, just copy the contents of the `src` in the official library into `lib` (`require_once(__DIR__."/../../lib/FacebookAds/Api.php");` :: `SdkConverter/main.php`) – Paradoxis Jul 12 '16 at 07:42
  • @Simon_Weaver seems like I forgot to add that feature (Facebook uses a lot of crud methods, which we never used), could you maybe open an issue on GitHub? For now you could simply fetch all ads from the related campaign, and loop over it until you find the ID – Paradoxis Jul 12 '16 at 07:49
  • I can do that in the morning thanks. I'm in bed here in California but thank you very much for your help. :) – Simon_Weaver Jul 12 '16 at 07:51
  • @Simon_Weaver no problem! Sleep well haha – Paradoxis Jul 12 '16 at 07:51
  • I'm awake now :-) Are you going to get a chance to update to 2.9 soon? Thanks! – Simon_Weaver Jun 09 '17 at 21:30
  • @Simon_Weaver changed the version string to the latest – Paradoxis Jun 11 '17 at 12:25
  • Now that your library is not maintained anymore, you might want to reconsider/edit this answer so that new folks reading this (like myself) are not lead to use it. – julealgon May 09 '22 at 21:04
2

The SDK I developed called the Facebook .Net SDK will do this. http://facebooksdk.codeplex.com The SDK supports .Net 3.5 and .Net 4.0. If you can, I would recommend using .Net 4.0 as the experience will be better.

Example code using dynamic on .net 4.0 would be:

FacebookApp app = new FacebookApp();
dynamic parameters = new ExpandoObject();
parameters.method = "ads.estimateTargetingStats";
parameters.account_id = "account_id";
parameters.targeting_spec = new List<string> { "spec1", "spec2" };
parameters.currency = "USD";
dynamic result = app.Api(parameters);
// from here just access the properties dyanmically
string s = result.something; // I dont remember exactly what all the return values are. You can view the dynamic result if you set a breakpoint when debugging.
Nate Totten
  • 8,904
  • 1
  • 35
  • 41
  • I downloaded your SDK through Nuget but do not see the FacebookApp class defined anywhere. – Kesty Nov 27 '14 at 16:31