Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read after write not working for adimages? #50

Closed
joephayes opened this issue Jul 17, 2018 · 10 comments
Closed

read after write not working for adimages? #50

joephayes opened this issue Jul 17, 2018 · 10 comments
Labels

Comments

@joephayes
Copy link

No matter what I put in fields I always get back image hash and url

I modified the example image_upload.rb file as follows:

images = ad_account.adimages.create({
  logo1: File.open(File.expand_path("../logo1.jpg", __FILE__)),
  logo2: File.open(File.expand_path("../logo2.png", __FILE__)),
  fields: ['name','hash']
})

and the object I get back contains hash and url attributes.

#<FacebookAds::AdImage {:hash=>"XXXXXXXXXX", :url=>"https://scontent.xx.fbcdn.net/v/t45.1600-4/XXXXXXXXXX"}>

Is read after write supported for ad images?

@joaquincorrales
Copy link

I don't think so. What are you trying to accomplish?

Also, do you know if there's anyway for us to catch error codes? The exception for a limited app or an invalid access token can only be caught as a string with a begin rescue.

@joephayes
Copy link
Author

joephayes commented Jul 17, 2018 via email

@joaquincorrales
Copy link

The name of the image is assigned on upload. Use that name and the hashes that come back

@joephayes
Copy link
Author

Also, do you know if there's anyway for us to catch error codes? The exception for a limited app or an invalid access token can only be caught as a string with a begin rescue.

I don't.

@joephayes
Copy link
Author

joephayes commented Jul 18, 2018

One thing I did find is that we can get to the last API response:

...
results = ad_account.adimages.create(files_to_upload)

last_response = ad_account.last_api_response

puts last_response

returns something like this:

#<FacebookAds::APIResponse:0x0000XXXXXXX @status_code=200,
@headers={"access-control-allow-origin"=>"*", "pragma"=>"no-cache", "cache-control"=>"private, no-cache, no-store, must-revalidate", "facebook-api-version"=>"v3.0", "expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "x-fb-rev"=>"4114154", "content-type"=>"application/json; charset=UTF-8", "x-fb-trace-id"=>"XXXXXXX", "strict-transport-security"=>"max-age=15552000; preload", "vary"=>"Accept-Encoding", "x-fb-debug"=>"XXXXXXX", "date"=>"Wed, 18 Jul 2018 14:04:01 GMT", "connection"=>"close", "content-length"=>"425"},
@body="{\"images\":{\"elephant.png\":{\"hash\":\"XXXXX\",\"url\":\"https:\\/\\/scontent.xx.fbcdn.net\\/v\\/t45.1600-4\\/XXXXX\"},\"nodejs-logo.png\":{\"hash\":\"XXXXX\",\"url\":\"https:\\/\\/scontent.xx.fbcdn.net\\/v\\/t45.1600-4\\/XXXXX\"},\"MongoDB-Logo.png\":{\"hash\":\"XXXXXX\",\"url\":\"https:\\/\\/scontent.xx.fbcdn.net\\/v\\/t45.1600-4\\/XXXXXXXX\"}}}">

That would allow you to check for status codes, etc. I was able to grab both the name and hash from the response, so that resolved my immediate issue.

@joephayes
Copy link
Author

Could someone from Facebook weigh in here though? Are there plans to support read after write when creating ad images? Or is it already supported and I did something wrong in my code?

@alanho
Copy link
Contributor

alanho commented Jul 19, 2018

are you trying to get the name of the image from read-after-write? read-after-write is supported in /adimages it's just name of the images will be the key of the hash returned. and the sdk do not extract the key and put it in AdImage object currently

@joephayes
Copy link
Author

@alanho - Thanks for the response and that it what I'm doing. I did realize the name comes back in the response and so I'm using the last_api_response property of the ad account to get at them (see my comment above - #50 (comment))

If this is the case, then what is the use of the fields key when you create ad images? See the example image upload file - https://github.com/facebook/facebook-ruby-business-sdk/blob/master/examples/image_upload.rb

@stale
Copy link

stale bot commented Jan 14, 2020

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.

@stale stale bot added the Stale label Jan 14, 2020
@stale
Copy link

stale bot commented Jan 21, 2020

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.

@stale stale bot closed this as completed Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants