Official Twitter Ruby Ads SDK

ruby
sdk
api

#1

Hi everyone,

We are trying to use the [official twitter ads sdk][1] to create a promoted tweet with a website card in order to generate conversions. We’ve run into a few issues:

  • It seems the SDK doesn’t have the ability to create a tweet, is this a feature in progress or by design?
  • The ‘PromotedTweet’ class members are all read only, is it impossible to create a promoted tweet through the SDK?
  • We can’t figure out how to attach a ‘WebsiteCard’ to a tweet.

Thanks!
Jonathan
[1]: https://github.com/twitterdev/twitter-ruby-ads-sdk


#2

@billyyotpo apologies for the delayed response here.

You are correct that we haven’t implemented native support for POST /accounts/:account_id/tweet just yet. This will be implemented along with promoted video support in the v0.3.0 release scheduled for next week.

That being said, you have a couple of perfectly viable work arounds in the meantime:

  • You can use the community twitter gem (it works well alongside the Ads API SDK) and call the /1.1/statuses/update.json endpoint in the public API with the parameter nullcast=true set.

  • You can use the TwitterAds::Request class directly to make calls to POST /accounts/:account_id/tweet.

The second approach is probably the easiest and allows you to leverage other Ads API specific features like Tweet delegation. Once you have the Tweet itself created, you can promote it on a specific line item quite easily using the following code:

promoted_tweet = TwitterAds::PromotedTweet.new(account).new
promoted_tweet.line_item_id = line_item.id
promoted_tweet.tweet_id     = 643609698231525376
promoted_tweet.save

I’ve created a full example that also shows how to use a Card in your Tweet here:
https://gist.github.com/brandonblack/90ed8632034d1b87d561

We also just released a new version of the SDK today v0.2.1 which includes some Card related fixes. I’d recommend grabbing that.


#3

Thanks for all the help @brandonmblack.
In the gist you supplied you assign the ‘line_item_id’ and ‘tweet_id’ properties of the PromotedTweet object. Both fields are read only hence these assignments yield a ‘NoMethodError’ for ‘line_item_id=’ and ‘tweet_id=’.

I’ve already forked the SDK in order to support working with the sandbox api (saw your comment on my ‘sandbox’ branch, thanks). Shall I just remove the read-only limitation from these fields in my fork or is there some other way to accomplish this?


#4

@billyyotpo ugggh. That’s a terribly embarrassing bug. I’m working on a branch where we’ve enabled write functionality on that object. Yes, I’ll get a release out today to fix that and add some proper test coverage for it.


#5

Hey @brandonmblack,
Any updates on the v0.3.0 release?