WooCommerce API and product image upload - woocommerce

I'm using the Google Books API to populate a WooCommerce database but I can't upload the images because I get this error:
{
"code": "woocommerce_product_invalid_image_id",
"message": "#593 is an invalid image ID.",
"data": {
"status": 400
}
}
WebP image link:
http://books.google.com/books/content?id=lYpxPQAACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api
I have found a solution that uses another API and converts the WebP image to a JPG image so that the API can upload it without problems, but for other reasons I don't want to use it.
Given the fact that with some plugin WooCommerce can easily handle WebP images, my question is:
Is there any way to not require uploading the image and instead just link to the WebP image?

Related

How to make wordpress post after API request

I've made a custom WordPress post and it has many fields to input.
Also, I've made a custom plugin that calls the API from the other site and creates posts using the API results.
The other things are working well.
But in my custom posts, there's a gallery to show the thumbnail images and I can get the image urls from the API.
"Images": [
{
"Priority": "0",
"Caption": "",
"Uri": "https://images.boatsgroup.com/images/1/68/46/7376846_20200225094022955_1_XLARGE.jpg",
"LastModifiedDateTime": "2020-02-25T09:49:53-08:00"
}]
enter image description here
So I've added the images manually to check where the images are saved in the database.
But I am not sure.
I want to know:
Where can I find the saved data for the gallery in the database?
How to create posts using the image URLs from API results automatically?
If anybody has experience in this kind of problem, help me, please.

How to get Firebase Dynamic Link URL social metadata itself

Say I have original URL: https://flutree.web.app/NWfLo\
And I shorten it using Firebase Dynamic Link, and set with Social Metadata (image, title, desc), it becomes new URL : https://flut.page.link/hcpa
Now I want to have a Link Preview functionality, I'm using simple_url_preview package. Basically, the package did a GET request of the new URL and parse the og(s) property from the body.
The problem is, it returns the metadata of the original URL, as depicted below:
Behavior that I want to achieve is as below (Example from Telegram's Link Preview, same behavior observed on other major platform ie Twitter, WhatsApp etc):
So, how can I get the metadata of the Firebase Dynamic link itself and not the original/target URL?

Get main picture URL of LinkedIn user

When requesting Basic Profile Fields for a specific user we get back the following:
picture-url, a URL for a square profile picture with a size of
100x100 pixels.
picture-urls, a list containing URLs for the original uploaded
picture.
What I need is the user's picture in square size and in a higher quality.
I know that the user's main picture (the one that is available on his/her profile page under https://www.linkedin.com/in/[user_id]/) is the size of 200x200 pixels, which is much better.
How can I access this picture URL through the API?
Remark: If I try to just generate this URL I get Access Denied error.
The LinkedIn API does not have any documented way to access the different sizes of the generated images. You can use picture-urls::(original) field to get the original uploaded picture URL and then scale it as you like. The original uploaded image can be even larger than 200x200 that the LinkedIn profile uses.
https://developer.linkedin.com/docs/fields/basic-profile
picture-urls::(original) A URL to the member's original unformatted
profile picture. This image is usually larger than the picture-url
value above.
API Call
GET: /v1/people/~:(id,first-name,last-name,picture-url,picture-urls::(original))
Result
{
"firstName": "Christos",
"id": "...",
"lastName": "Litras",
"pictureUrl": "https://media.licdn.com/dms/image/C5603AQHcTGe3GOQviw/profile-displayphoto-shrink_100_100/0?e=1528894800&v=beta&t=JzgIhDOm-xGxIEuQP1jy3sFHRAeN5pk5skHhXm9s3wM",
"pictureUrls": {
"_total": 1,
"values": [
"https://media.licdn.com/dms/image/C5600AQG-fzvmQVCLsg/profile-originalphoto-shrink_900_1200/0?e=1528894800&v=beta&t=TrtntJgtAHeolrPeteffiq_Ixg-JecaAvutQioy0c8A"
]
}
}

WooCommerce API creates images in media even if they exist

What might be a reason?
Trying to batch update product images (and price) in WooCommerce via REST API. Images already exist in wordpress media library and links are correctly copied. However, instead of using image it creates new image.
Request: POST.
URL: https://SiteURL/wp-json/wc/v2/products/xxxx?consumer_key=c______&consumer_secret=_____
Body:
{"update":[
{"regular_price":"448",
"images":[
{"src":"https://urlToImage.jpg",
"position":0, "name": "test"}
],"id":"xxxx"}]}
In response I can see it creates image with the same url but as there is already an image in the library, it adds -1 to url.
Thank you in forward :)
Since this is an update where the images already exists you need to set the id member of the images element. Otherwise, WooCommerce interprets this as a request to add a new image to the product gallery.

How to get the Woocommerce API to not upload images when creating product

I'm using the Woocommerce API to create products, and passing in an array of image urls. The images are on S3, and I just want Wordpress to reference those, but by default the Woocommerce API uploads the images to Wordpress and references those.
Any ideas how I can change this behavior so that the just takes the remote image URL's and uses those?
Thanks!
Not possible WooCommerce uses the Post ID of photo uploaded to WordPress as it's primary identifier (key) to reference those images...
If you DO find out how to do that, that would be huge!!
Good luck
Yes, you can pass the image as a parameter of products from the third party URL. still, it is not accessing from the phone.
try like this
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg",
"position": 0
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg",
"position": 1
}
]
You can find the more information from the docs of woocommerce REST API.
Visit https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

Resources