effilab / bing_ads_ruby_sdk Goto Github PK
View Code? Open in Web Editor NEWRuby SDK for Bing Ads API (src: https://github.com/Effilab/bing_ads_ruby_sdk)
License: MIT License
Ruby SDK for Bing Ads API (src: https://github.com/Effilab/bing_ads_ruby_sdk)
License: MIT License
Hello folks,
It doesn't look like there is a forum, Discord or anything, so I'm asking here.
I've looked through the code ( https://github.com/Effilab/bing_ads_ruby_sdk/blob/adf0fba04d968bf2528783270c22dbf2dc708b81/lib/bing_ads_ruby_sdk/services/reporting.rb ), and it's unclear to me so far how to make use of the reporting services through your gem.
Would it be possible to get an example of code that works or some documentation around it?
Maybe it's just because I'm very rusty with SOAP, but we can't figure it out so far, even getting a decent error message from the API response isn't really clear.
What worked for us is getting a list of accounts:
@api = BingAdsRubySdk::Api.new(oauth_store: @store,
developer_token: ENV["MICROSOFT_ADVERTISING_DEVELOPER_TOKEN"],
client_id: ENV["MICROSOFT_ADVERTISING_CLIENT_ID"],
client_secret: ENV['MICROSOFT_ADVERTISING_SECRET_VALUE'])
@store.write({access_token: access_token, refresh_token: refresh_token,
expires_in: expires_in, expires_at: expires_at, issued_at: token_issued_at})
@api.customer_management.find_accounts_or_customers_info(filter: "", top_n: 1000)
This all works fine.
But when trying to fetch a report, as there is no doc, we decided to create our own XML query like this (maybe wrongly so):
xml_query = <<~XML
<ReportRequest type="AccountPerformanceReportRequest" i:nil="false" i:type="-- derived type specified here with the appropriate prefix --">
<Aggregation>Summary</Aggregation>
<Columns i:nil="false">
<AccountPerformanceReportColumn>AccountName</AccountPerformanceReportColumn>
<AccountPerformanceReportColumn>Clicks</AccountPerformanceReportColumn>
</Columns>
<Scope i:nil="false">
<AccountIds i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:long>OUR_ACCOUNT_ID</a1:long>
</AccountIds>
</Scope>
<Time i:nil="false">
<CustomDateRangeEnd i:nil="false">
<Day>25</Day>
<Month>4</Month>
<Year>2023</Year>
</CustomDateRangeEnd>
<CustomDateRangeStart i:nil="false">
<Day>1</Day>
<Month>5</Month>
<Year>2023</Year>
</CustomDateRangeStart>
</Time>
</ReportRequest>
XML```
and call it with:
```ruby
begin
res = @api.reporting.call(:submit_generate_report, report_request: xml_query)
rescue => ex
p ex
puts ex.message
raise
end
Sadly, we are getting a pretty generic error:
/Users/.../.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bing_ads_ruby_sdk-1.5.2/lib/bing_ads_ruby_sdk/errors/error_handler.rb:15:in `call': Bing Ads API error - The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. (BingAdsRubySdk::Errors::GeneralError)
Any idea how we could get a report to get generated? Or to get the details about the error?
Thanks so much
After installing the gem the rake task is not found in the list of available tasks.
rake bing_token:get[bing_token.json,1070T4E69T912273,687249]
rake aborted!
Don't know how to build task 'bing_token:get' (See the list of available tasks with `rake --tasks`)
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
undefined
, standard
)Gemfile
standard "1.32.1"
.circleci/config.yml
ruby 3.2.2
.ruby-version
ruby 3.0.6
Hi, could you please release new version of gem? Because latest version doesn't include this changes #79
I know, that I can set branch: 'master'
in the my Gemfile, but it is not best practise
Thank you
Tried to run rake bing_token:get[my_token.json,your_dev_token,your_bing_client_id] but it returns
rake aborted!
Don't know how to build task 'bing_token:get' (See the list of available tasks with `rake --tasks`)
Did try to copy rake file to my project task directory and id did run but returns
invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application.
Sometimes it has error unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?
What should be the correct steps to generate token?
These URLs are for production accounts.
SCOPE = "https://ads.microsoft.com/msads.manage"
AUTHORIZE_URI = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
TOKEN_URI = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
REDIRECT_URI = "https://login.microsoftonline.com/common/oauth2/nativeclient"
Instead of these, we need to add sandbox URLs based on :environment
.
Nothing seems to work but Im guessing its because we are using the wrong IDs. Microsoft makes it impossibly difficult to find these IDs.
Any idea where we find: Parent Customer ID, Customer ID, Account ID?
Firstly, I just wanted to say thanks for creating this library in the absence of an official one from Microsoft.
While using the library, I noticed that errors are not raised and the only way to know if operations failed is to look into the logs. Was this intentional? It would be useful if errors were raised so one could halt their code from proceeding on an api error and know immediately what the error message is.
Based on some random code samples, I just tried this after manually running the rake task to get the access_token:
2.6.3 :012 > x = api.campaign_management.call(:get_campaigns_by_account_id, account_id: 'XXXXXXX')
Where the account Id I got from the aid parameter in Bing reporting.
But when I run it, I get this response:
=> {:faultcode=>"s:Server", :faultstring=>"Invalid client data. Check the SOAP fault details for more information. TrackingId: f4edb9a7-3e5c-47d5-9c60-d0a5882a5540.", :detail=>{:ad_api_fault_detail=>{:tracking_id=>"f4edb9a7-3e5c-47d5-9c60-d0a5882a5540", :errors=>{:ad_api_error=>{:code=>"105", :detail=>nil, :error_code=>"InvalidCredentials", :message=>"Authentication failed. Either supplied credentials are invalid or the account is inactive"}}}}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.