Using imgBB api in livecode (solved)

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Using imgBB api in livecode (solved)

Post by BigameOver » Thu Sep 24, 2020 8:18 pm

Hi,
I tried to use the imgBB api in livecode, but it didn't worked well for me.
https://api.imgbb.com/
Do you know how can i use it in my program?
I have the basic free livecode edition if that matters
Thank you
Last edited by BigameOver on Sun Sep 27, 2020 1:21 pm, edited 2 times in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Using bbimg api in livecode

Post by FourthWorld » Thu Sep 24, 2020 8:37 pm

LC supports sockets, and provides a library using sockets for HTTP. You can start with the GET and POST commands in the Dictionary, and chime back in if there's anything in the API that's not clear on how to call it from LC.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using bbimg api in livecode

Post by BigameOver » Fri Sep 25, 2020 5:58 pm

Hi FourthWorld,
I tried to do this code but when i run it livecode crashes:

Code: Select all

on mouseUp
   put base64Encode(image "my_image") into _tImage
   request POST "https://api.imgbb.com/1/upload?key=YOUR_CLIENT_API_KEY?image=" & _tImage
end mouseUp
What can I do?
Thanks

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using bbimg api in livecode

Post by Klaus » Fri Sep 25, 2020 6:29 pm

BigameOver wrote:
Fri Sep 25, 2020 5:58 pm
What can I do?
The dictionary is really helpful with these things! 8)
This should do:

Code: Select all

on mouseUp
   put base64Encode(image "my_image") into _tImage
   POST _timage to URL "https://api.imgbb.com/1/upload?key=YOUR_CLIENT_API_KEY?image="
end mouseUp
But LC should NEVER crash! :(

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using bbimg api in livecode

Post by BigameOver » Fri Sep 25, 2020 7:23 pm

Hi Klaus,
Unfortunaly, It doesn't work for me :(
When I answer it it says ""status_code":400,"error":{"message":"Invalid API v1 key.","code":100,"context":"Exception"},"status_txt":"Bad Request"

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using bbimg api in livecode

Post by Klaus » Sat Sep 26, 2020 8:14 am

If your api key is correct, what the error tries to tell you, try this:

Code: Select all

on mouseUp
   put "image=" & base64Encode(image "my_image") into _tImage
   POST _timage to URL "https://api.imgbb.com/1/upload?key=YOUR_CLIENT_API_KEY?"
end mouseUp

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using bbimg api in livecode

Post by BigameOver » Sat Sep 26, 2020 8:51 am

Klaus wrote:
Sat Sep 26, 2020 8:14 am
If your api key is correct, what the error tries to tell you, try this:

Code: Select all

on mouseUp
   put "image=" & base64Encode(image "my_image") into _tImage
   POST _timage to URL "https://api.imgbb.com/1/upload?key=YOUR_CLIENT_API_KEY?"
end mouseUp
My api key is correct but now it says this:
{"status_code":400,"error":{"message":"Invalid base64 string.","code":120,"context":"Exception"},"status_txt":"Bad Request"}
How can I fix this?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using bbimg api in livecode

Post by Klaus » Sat Sep 26, 2020 12:03 pm

Sorry, out of ideas...

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using bbimg api in livecode

Post by BigameOver » Sat Sep 26, 2020 12:27 pm

Does anybody else know?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Using bbimg api in livecode

Post by FourthWorld » Sat Sep 26, 2020 7:54 pm

What headers are required by the API? And have you successfully authenticated?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using bbimg api in livecode

Post by BigameOver » Sat Sep 26, 2020 8:02 pm

FourthWorld wrote:
Sat Sep 26, 2020 7:54 pm
What headers are required by the API? And have you successfully authenticated?
The key and the image are required by the API. I got my key from the site and just copied it.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Using bbimg api in livecode

Post by FourthWorld » Sat Sep 26, 2020 8:09 pm

Have you been able to use those successfully in Postman or other tool outside of LC?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using imgbb api in livecode

Post by BigameOver » Sat Sep 26, 2020 8:24 pm

FourthWorld wrote:
Sat Sep 26, 2020 8:09 pm
Have you been able to use those successfully in Postman or other tool outside of LC?
I haven't heard of postman as it is my first time trying to use an API in livecode but searching this on google with imgbb leading to zero result

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Using imgBB api in livecode

Post by FourthWorld » Sat Sep 26, 2020 8:59 pm

Postman is a very popular tool for testing HTTP-based APIs.
https://www.postman.com/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BigameOver
Posts: 39
Joined: Thu Jan 23, 2020 5:56 pm

Re: Using imgBB api in livecode

Post by BigameOver » Sat Sep 26, 2020 9:22 pm

FourthWorld wrote:
Sat Sep 26, 2020 8:59 pm
Postman is a very popular tool for testing HTTP-based APIs.
https://www.postman.com/
Hi,
I tried to use the API in Postman with the example on the imgBB's site but it only says in the status: 404 Not Found
What I don't do right?

Post Reply

Return to “Internet”