facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
208 stars 161 forks source link

load! is not supported for this object #75

Closed jairobluecaribu closed 5 years ago

jairobluecaribu commented 5 years ago

Which SDK version are you using?

Hello,

I am using facebookbusiness-0.4.0.1

and when I try to get all actions for one account, I receive the next error.

Traceback (most recent call last): 4: from fb_ads.rb:49:in <main>' 3: from /usr/local/rvm/gems/ruby-2.5.1/gems/facebookbusiness-0.4.0.1/lib/facebook_ads/edge.rb:46:ineach' 2: from fb_ads.rb:54:in block in <main>' 1: from /usr/local/rvm/gems/ruby-2.5.1/gems/facebookbusiness-0.4.0.1/lib/facebook_ads/fields.rb:48:inblock in define_reader' /usr/local/rvm/gems/ruby-2.5.1/gems/facebookbusiness-0.4.0.1/lib/facebook_ads/helpers/node_helpers.rb:46:in `load!': load! is not supported for this object (RuntimeError)

This is my code:

ad_account = FacebookAds::AdAccount.get('act_some_account_id')

ad_account.insights(fields: 'cpc,clicks,cost_per_conversion,ctr,impressions,reach,spend,actions', time_range: "{'since':'2019-06-01','until':'2019-06-30'}", ).each do |insights| ap insights.actions end

but when I print only "insights", I get:

{ :cpc => "177.813025", :clicks => "9996", :ctr => "2.209056", :impressions => "452501", :reach => "213311", :spend => "1777419", :actions => [ [ 0] { :action_type => "onsite_conversion.messaging_first_reply", :value => "1" }, [ 1] { :action_type => "onsite_conversion.messaging_conversation_started_7d", :value => "1" }, . . ..... }

there is some wrong with my code?

thanks you,

jairobluecaribu commented 5 years ago

I close de issue, I´m wrong

the correct way to get the value is insights["actions"][11]["value"] (for example) and not insights.actions

my bad