Adding image from google drive into google slideshow with API - python-3.x

I'm trying to add an image that I've uploaded to Drive via the Drive API into a slide show I've created using the same API.
when Running the fairly standard:
response = (self
._slides_service
.presentations()
.batchUpdate(presentationId=slide_deck_id, body=body)
.execute()
)
I get:
googleapiclient.errors.HttpError: <HttpError 400 when requesting {url} returned "Invalid requests[0].createImage: The provided image is in an unsupported format.">
I'm generating the service in the same way as suggested in the documentation here: https://developers.google.com/slides/quickstart/python
My scope is:
https://www.googleapis.com/auth/presentations
If I run the command with a random png from the internet then it inserts the image fine. I've tried the url provided by webContentLink or WebViewLink values from the response from uploading the images. Neither are valid.
What URL will work to do this?
I'm aware there are other similar questions on stack overflow but all of them are not related to doing this in python or if they are, there solutions don't work.
EDIT:
body is:
{'requests': [{'createImage': {'url': url, 'elementProperties': {'pageObjectId': page_id}}}]}
had to generalise the url and page id because GDPR is a pain.

Related

Publishing Custom Vision Azure in Website

I made a image classification using custom vision and published it. After that I got this publishing url and prediction key. Now I am literally confused how to use this as a api in a website that I am making using MERN.
Also the prediction url doesnt work- "{"error":{"code":"404","message": "Resource not found"}}"
This is the ouput details after publishing:
If you have an image URL:
https://assam-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/**2/classify/iterations/TradiitionalVsWestern/url
Set Prediction-Key Header to : ***
Set Content-Type Header to : application/json
Set Body to : {"Url": "https://example.com/image.png"}
I reproduced the same thing in my environment. When you are request via GET method you will get a 404 error for predication. You can use prediction call by using the POST method as per MS document
To resolve the above use POST method and follow the steps.
You can use both image and Image URL.
Syntax of my prediction URL
https://democustv-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/ecsxx /classify/iterations/Iteration1/image
Select your image down here
Now everting is working fine 200 OK.

Instagram oEmbed - URL signature mismatch for thumbnail_url

Is there any way how to correctly fetch the thumbnail image for video from Instagram oEmbed?
The typical thumbnail_url in oEmbed response now is https://scontent-cdg2-1.cdninstagram.com/vp/5c0c62bb1aec72c31a9e72680b9d839b/5C37201B/t51.2885-15/sh0.08/e35/p640x640/47693743_354556005338968_7959923928510913600_n.jpg that produces "URL signature mismatch" instead of the image.
What you need to do, is to use the shortlink provided by instagram, you can find this or either via the embed function in the UI or via the API, In the API shows as 'link', then add '/media' at the end, this will redirect to the resource without need to sign the calls.
Hope helps

Unable to download video from Google Photos API baseUrl

I am trying to download a video from {baseUrl=dv}. ( URL 1 )
After that the page on this URL was redirected and getting a 500 error ( URL 2 ).
What's missing?
There is currently a known issue with base URLs for videos. Accessing the video via the dv parameter returns a 500 Error.
You can follow along on the issue tracker here: https://issuetracker.google.com/111638708 ("Star" the issue to be notified of any updates.)

google cloud vision 403 permission denied error(other questions didn't work)

I am trying to perform OCR on pdf documents using google cloud vision API, i uploaded a pdf document into a cloud bucket and downloaded the oauth key file and added it in the script as below. But when i run the file, i get the permissiondenined: 403 error, can anyone please give me instructions on how to fix it, i did extensive google search and did not yield any results, i am surely missing something here.
#authenitcation file
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="mykeylocation/key1.json"
#method being called
operation = client.async_batch_annotate_files(requests=[async_request])
#error message
PermissionDenied: 403 Error opening file: gs://myocrbucket-vamsi/2017 Form 3W-2.pdf.
I have checked the older stack overflow questions and the links provided in answers are not active anymore.
Thanks in advance for your help.
Add your client_email to member of your bucket and give necessary role(s) for it, find it from your json key file.
Storage Bucket -> Permissions -> Add member

php library for flickr API

I am banging my head trying to use Flickr API...
My goal is to be able to upload images and create albums in my Flickr account from my website...
I tried the phpFlickr library but apparently it needs updates for getting authenticated tokens...It keeps giving me "Invalid auth token".
I did some reading on how to get tokens and using DPZFlickr managed to get oauth_token & oauth_verifier but failed to exchange that with an access token...It also failed in uploading any photo to my account using the included upload.php example (Giving me an "empty" error!).
After digging in DBZ flickr.php code, I managed to get this error when trying to upload to Flickr: "oauth_problem=signature_invalid&"
So I began to search how to create a valid signature to eventually get a valid access token...and concluded that it is quite some work to be done here if I am going to build everything from scratch.
So my question is: Are there any updated php libraries that I can use to successfully create albums and upload photos to my Flickr account? Or should I go ahead and try building one?
OK..I finally got it to work with the DPZ library.
For future reference anybody facing the same problem as I had:
I managed to create an album using DPZFlickr by changing the method in auth.php to flickr.photosets.create....which indicated that the library correctly generates an access token with write permission..
However, the upload example kept giving me the "Invalid signature" error....
I checked the code. Flickr.php correctly unsets the photo parameter before signing the request then adds it back and submits the request which is exactly as indicated in: www.flickr.com/services/api/upload.api.html
I found a discussion in https://www.flickr.com/groups/51035612836#N01/discuss/72157650261711318/ that cleared out that the error was not actually a signature problem, but rather the 'photo' parameter that is being sent is the problem. It's just that Flickr doesn't know what to do with the photo parameter so it sends the signature error.
So what' wrong with the photo parameter?
Flickr API requires that the image has to be sent in binary form...The DBZ library, Flickr.php script line 677, does the hard work for us using the cURL function in php (http://au.php.net/manual/en/function.curl-setopt.php).
It sends the $parameters (which includes the uploaded photo) to the post field of the http request which should do the upload in binary format for us.
However, a brilliant comment I found in CURL PHP send image
states that:
"CURLOPT_SAFE_UPLOAD defaulted to true in 5.6.0... so you will need to add curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); before setting CURLOPT_POSTFIELDS"
Checking the manual: http://au.php.net/manual/en/function.curl-setopt.php
it says:
"Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 changes the default value to TRUE."
So if your php version is 5.5.0 the library will work just fine whilst if using version PHP 5.6.0 you need to add a line before 677 in Flickr.php to change the CURLOPT_SAFE_UPLOAD to false (that's why the library works with some and others not).
To solve the issue...Just add this line before line 677 in Flickr.php:
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);
That's it. (-:

Resources