Can anyone please help me to implement tiny png api in my app

I have limited knowledge on the web component so can anyone please help me to implement TinyPng API in my app.

https://tinypng.com/developers/reference

I had been using these blocks but this does not work :


blocks(1)

Check your Headers:

1 Like

Also use the POST method together with the image

Taifun

1 Like

Based on the suggetions of @Ded_Sec_00 and @Taifun I have made some changes but it still doesnt work.


I have also tried this one :

In the API reference of TinyPNG :

Delete the space and : in your Headers. Look at my pinned Post.
I think the /shrink has to be on the end of the API URL in the Web URL and you have to use Put File.

I have tried but it doesnt work.

Thanks anyway.

The post data contains the image binary ie multipart//form data . So ,

It can be solved by sending binary data from the extension. Can you send me the api documentation ?

https://tinypng.com/developers/reference

Yeah, here i found a specific API from Tinify. However, I don’t feel that api is made for android too as it is reported to crashing on device with

~~main java.lang.NoClassDefFoundError: java.nio.file.Paths~~

As android doesn’t supports java 7 fully and java.nio.file.Paths is added on java 7.

Since, its open-source , i will modify library and update result here !

1 Like

also you have to set the url property, which is https://api.tinify.com/shrink
and: first set the url and the header, then use the Post method together with the image
also remove the Get method…
and in the Web.GotText event display the response content in a label…

you might want to try this and if you get stuck, post a screenshot of your updated relevant blocks

Taifun
PS: no need to use an extension…

1 Like

@Taifun


tried this one but it still doesnt work

it shows the same error as the earlier ones :

this looks almost fine…

  1. but why did you remove the Basic in front of your authorization key?
    it should be Basic nR...
  2. I think, it will also work without the Host header…

Taifun

@Taifun I tried that too but it still doesn’t work.

which response content do you get in the Web.GotText event?
did you try this

Unbenannt

you also might want to use Do it to find out the path of Image1.Picture… is it suitable to use for the Web.Post method?
use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun