ads API Support

May 4, 2015 at 1:29 PM
Hello,
I am planning on using Tweetinvi with the ads API
is there a support for it
or at least is there a way to send POST and GET requests using Tweetinvi ?
Thanks
Coordinator
May 4, 2015 at 3:54 PM
Hi,

I have never tested the Ads API of Twitter. I first need to finish implementing the REST API before I can continue on more.
From what I was able to read, Tweetinvi should be able to access the Ads API thanks to the Twitter Accessor.
var json = TwitterAccessor.ExecuteJsonGETQuery("https://ads-api.twitter.com/0/accounts");
Now you need to be careful because it seems like the application need to have special authorization in order to access the Ads API.

https://twittercommunity.com/t/application-only-authentication/27846

I do not have any knowledge about this, so please get some info on your end.

Please keep me up to date. I am very interested in bringing this feature after the release 1.0 Tweetinvi. Any feedback could be very valuable.

Thanks,
Linvi
May 4, 2015 at 4:07 PM
Thanks Linvi,
As for the Ads API you need special access to use it and we're currently working on getting the access
The GET Call seems what I need I have never seen it in tweetinvi ,how about post requests , how can I send parameteres using the POST request?
Whenever we get the access and implement I'll share my implementation so it will be easier to implement at ur end later on
Coordinator
May 4, 2015 at 4:12 PM
Edited May 4, 2015 at 4:13 PM
Hi,

The TwitterAccessor is full of useful methods you can use to do any request you want. All WebRequests in Tweetinvi uses the TwitterAccessor.
You can for example get a Model from the Json response by just specifying the type of object you want as a Generic.
public class Ad
{
    public long Id { get; set; }
    public long Title { get; set; }
}

// Execute POST request
var ad = TwitterAccessor.ExecutePOSTQuery<Ad>("https://ads-api/createNewAd");
This will automatically handle exceptions for you and return null if any occurred (if the ExcetpionHandler is turned on).

Cheers,
Linvi
Coordinator
May 4, 2015 at 4:17 PM
Where should I look for in order to have the special authorization you mentioned?

Linvi
May 4, 2015 at 4:18 PM
Thanks Again Linvi for the instant reply,
To be more precise I have been using the Facebook Ads API and facebook C# SDK say I have a post like
cfacebookclient.post(uri,new
{
value1=v1,
value2=v2
});
is there an equivalent way in tweetinvi to send values just like that ?
May 4, 2015 at 4:20 PM
Coordinator
May 4, 2015 at 4:26 PM
Hi,

Thanks for the info, I will have a look into it so that I can help you with more accuracy.

I have never thought about adding the parameters this way. I could add this feature in 0.9.9.x but it will not be available before 2 months at least.
At the current time you will have to generate the URL with the parameters on your own but you use a StringExtension available in Tweetinvi:
var ad = TwitterAccessor.ExecutePOSTQuery<Ad>("https://ads-api/createNewAd"
                .AddParameterToQuery("value1", "v1")
                .AddParameterToQuery("value2", "v2"));
Cheers,
Linvi
May 4, 2015 at 4:34 PM
Edited May 4, 2015 at 4:34 PM
Thanks for your help , I'll look into it more closely
Coordinator
May 4, 2015 at 10:33 PM
I have applied for the Ads API. I will let you if and when I have access.

Linvi