![]() |
VOOZH | about |
The CData Cmdlets for Twitter Ads are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Twitter Ads.
The Cmdlets are not only a PowerShell interface to Twitter Ads, but also an SQL interface; this tutorial shows how to use both to retrieve Twitter Ads data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Twitter Ads. To access Twitter Ads data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Twitter Ads.
Once you have acquired the necessary connection properties, accessing Twitter Ads data in PowerShell can be enabled in three steps.
All tables require authentication. You must use OAuth to authenticate with Twitter. OAuth requires the authenticating user to interact with Twitter using the browser. For more information, refer to the OAuth section in the Help documentation.
Install the module:
Install-Module TwitterAdsCmdlets
Connect:
$twitterads = Connect-TwitterAds -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$entity = "ORGANIC_TWEET" $adstats = Select-TwitterAds -Connection $twitterads -Table "AdStats" -Where "Entity = `'$Entity`'" $adstats
You can also use the Invoke-TwitterAds cmdlet to execute SQL commands:
$adstats = Invoke-TwitterAds -Connection $twitterads -Query 'SELECT * FROM AdStats WHERE Entity = @Entity' -Params @{'@Entity'='ORGANIC_TWEET'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Twitter Ads\lib\System.Data.CData.TwitterAds.dll")
Connect to Twitter Ads:
$conn= New-Object System.Data.CData.TwitterAds.TwitterAdsConnection("InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the TwitterAdsDataAdapter, execute an SQL query, and output the results:
$sql="SELECT EntityId, Entity from AdStats"
$da= New-Object System.Data.CData.TwitterAds.TwitterAdsDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.entityid $_.entity
}
Download a free trial of the Twitter Ads Data Provider to get started:
Download NowLearn more:
👁 Twitter Ads IconRapidly create and deploy powerful .NET applications that integrate with Twitter Ads.