Paradoxis / Facebook-CSharp-Ads-SDK

A third party Facebook Ads SDK (Marketing API) wrapper for C#
MIT License
15 stars 20 forks source link

How to use paging? #5

Open simeyla opened 6 years ago

simeyla commented 6 years ago

How am I supposed to do paging when the response returns back paging element?

I can take the URL and run it but how to do that within your API?

simeyla commented 6 years ago

This was the best I came up with. Wish it was 'built in' in some fashion.

   if (campaignInsights.paging != null && campaignInsights.paging.next != null)
   {
       var url = new Uri(campaignInsights.paging.next.ToString()).PathAndQuery;
       var urlWithoutAPIVersion = url.Substring(url.IndexOf("/", 1));  // skip API version in URL

       campaignInsights = JObject.Parse(Api.Client.Get(urlWithoutAPIVersion).ToString());
   }

This is where campaignInsights is the response from GetInsights() where paging was returned.

Paradoxis commented 6 years ago

As far as I know there currently isn't support for this in the SDK yet, I'll have to see how the official API does it and see if I can implement it in the next release :)