Closed joephayes closed 4 years ago
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.
I'm trying to upload images and I'd like to get back the hashes and the names of the images.
On Tue, Jul 17, 2018 at 7:28 PM Joaquin Corrales notifications@github.com wrote:
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.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/facebook-ruby-business-sdk/issues/50#issuecomment-405759982, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQPPhKVcvJwnSvKRjBHSXMu1LA-n-Oyks5uHnMbgaJpZM4VTrjr .
The name of the image is assigned on upload. Use that name and the hashes that come back
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.
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.
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?
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
@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 - https://github.com/facebook/facebook-ruby-business-sdk/issues/50#issuecomment-405943862)
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
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.
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.
No matter what I put in
fields
I always get back image hash and urlI modified the example image_upload.rb file as follows:
and the object I get back contains
hash
andurl
attributes.Is read after write supported for ad images?