Coder Social home page Coder Social logo

Comments (8)

joephayes avatar joephayes commented on April 26, 2024 6

This allows access to the headers of the request that caused the error:

begin
  ad_account = FacebookAds::AdAccount.get("act_#{ad_account_id}", 'name')

  puts "Ad Account Name: #{ad_account.name}"
rescue FacebookAds::APIError => e
  puts e.instance_variable_get(:@api_response).headers
end

produces this:

{"access-control-allow-origin"=>"*", "strict-transport-security"=>"max-age=15552000; preload", "x-fb-trace-id"=>"XXXXXX", "content-type"=>"application/json; charset=UTF-8", "x-fb-rev"=>"4116048", "x-app-usage"=>"{\"call_count\":0,\"total_cputime\":0,\"total_time\":0}", "cache-control"=>"no-store", "pragma"=>"no-cache", "expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "www-authenticate"=>"OAuth \"Facebook Platform\" \"invalid_token\" \"Invalid OAuth access token.\"", "x-fb-debug"=>"XXXXX", "date"=>"Wed, 18 Jul 2018 22:22:19 GMT", "connection"=>"close", "content-length"=>"113"}

from facebook-ruby-business-sdk.

joephayes avatar joephayes commented on April 26, 2024

Check the last_api_response of the ad object you are using. You can access the headers from there. See #50 (comment) for an example.

from facebook-ruby-business-sdk.

joaquincorrales avatar joaquincorrales commented on April 26, 2024

Joe thanks a lot. I'm also trying to handle an ad account being limited or app being limited and catching it with a begin -> rescue but the last_api_response can't be found in the rescue. Maybe I should just make sure it never happens as opposed to trying to handle when it does

from facebook-ruby-business-sdk.

joaquincorrales avatar joaquincorrales commented on April 26, 2024

I'm already performing some sort of "ping" to the ad account before performing anything so I might be good but you can never be too safe.

There's always the scenario that when you ping the adaccount everything is fine but halfway through processing they reach their limit you know

from facebook-ruby-business-sdk.

joaquincorrales avatar joaquincorrales commented on April 26, 2024

That helps tremendously thank you so much Joe!

One last question. Do you know if there's an option to not allow users to edit campaigns made through the API in their ads managers? Or is that impossible.

from facebook-ruby-business-sdk.

joephayes avatar joephayes commented on April 26, 2024

You are welcome! Unfortunately, I don't know if there is a way to block users from editing API created campaigns with Ads Manager. Sorry!

from facebook-ruby-business-sdk.

stale avatar stale commented on April 26, 2024

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

from facebook-ruby-business-sdk.

stale avatar stale commented on April 26, 2024

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

from facebook-ruby-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.