Twurl vs Oauth gem

oauth
ruby
sdk

#1

Hello people from twiter
I m having some doubts about the twitters ads fllow.
When I list the accounts ( with the GET method https://dev.twitter.com/ads/reference/get/accounts ) with differents ways, it retrieves differents accounts each one. With one way it gives me the certified account, and with the other it gives the “client” account. The last one is the account that I spected, but this differenses make me doubt.
To be more clear, in first place I use twurl, the tool that the API recomends. Following this example https://dev.twitter.com/ads/campaigns, when I list the accounts it retrieves the ads certified account account.
By other way I use ruby, the lenguaje that I’ll use in my app, with OAuth gem, and guided by https://dev.twitter.com/oauth/overview/single-user#ruby.Then I perform the GET method to get the accounts, but instead it retrieves the client account (the twitter account that gives acces to my account).
So It’s no clear what account should it retrieve. I think that the second way is the correct because to continue the creation of a campaign I need the funding instrument of the client, but the first way is the recomended for the example in the documentation.


#2

@prueba88888 twurl actually uses the same oauth gem so both approaches should be the same unless you’re using different user tokens (access tokens).

The only thing that would cause you to see different responses on GET /accounts would be if you did indeed use a different user token in twurl then you are in your own application. To be sure you’re making the twurl request under the right user, you can run twurl accounts to see the default being used.

For example:

~ ❯ twurl accounts
brandonmblack
  OIDntXZULiYrCzSBq23BQ (default)

On a related note, have you checked out the Ads API SDK for Ruby from Twitter? Accessing a specific account object or enumerating all accounts available to the user token using the Ruby SDK is quite simple.

# installing the latest release
gem install twitter-ads

require 'twitter-ads'

# initialize the client
client = TwitterAds::Client.new(
  CONSUMER_KEY,
  CONSUMER_SECRET,
  ACCESS_TOKEN,
  ACCESS_TOKEN_SECRET
)

# iterate through all accounts available to your access token
client.accounts.each do |account|
  # do something
end

# load a specific advertiser account instance
account = client.accounts('c3won9gy')