Using imgBB api in livecode (solved)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9850
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Using imgBB api in livecode
404 tells you the URL you're using is wrong. I'm not familiar with that API so I can't help with that part of it, but if that project has a forum I'll bet they can get you sorted on that part pretty quickly.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 76
- Joined: Tue Mar 05, 2013 7:00 pm
- Location: Berlin
- Contact:
Re: Using imgBB api in livecode
Hi, I've put together a small working sample stack to post to the imgBB Api.
Download it, open the stack script, add you API-Key and it works.
Select a file to upload,
it will appear in 2 Images of the card, img1 is referenced, image 2 contains the imagedata.
When you hit "upload Image 1" the Image is read from disk and the postdata is assembled using libURLMultipartFormData
When you hit "upload Image 2" the Imagedata is taken out of the image object (myImg2) and transferred to the upload function.
The result is shown in a TreeView widget at the bottom.
Set a breakpoint in line 71 and watch the variables, here you see how the function upload2imgbb is used.
Set another breakpoint in line 94 and look into the variable tform.
Line one contains the http headers which will be sent,
Line 2 to last line contains the data which will be posted.
I'll hope it helps
Download it, open the stack script, add you API-Key and it works.
Select a file to upload,
it will appear in 2 Images of the card, img1 is referenced, image 2 contains the imagedata.
When you hit "upload Image 1" the Image is read from disk and the postdata is assembled using libURLMultipartFormData
When you hit "upload Image 2" the Imagedata is taken out of the image object (myImg2) and transferred to the upload function.
The result is shown in a TreeView widget at the bottom.
Set a breakpoint in line 71 and watch the variables, here you see how the function upload2imgbb is used.
Set another breakpoint in line 94 and look into the variable tform.
Line one contains the http headers which will be sent,
Line 2 to last line contains the data which will be posted.
I'll hope it helps
- Attachments
-
- imgbbUpload.livecode.zip
- (3.79 KiB) Downloaded 345 times
-
- VIP Livecode Opensource Backer
- Posts: 9850
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Using imgBB api in livecode
"Working example"? You resolved the issue?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 76
- Joined: Tue Mar 05, 2013 7:00 pm
- Location: Berlin
- Contact:
Re: Using imgBB api in livecode
Yes it works, tested it
From the imgbbdocs:
curl --location --request POST "https://api.imgbb.com/1/upload?expirati ... NT_API_KEY" --form "image=R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
It is send as form data
I 'll hope it will help BigameOver
From the imgbbdocs:
curl --location --request POST "https://api.imgbb.com/1/upload?expirati ... NT_API_KEY" --form "image=R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
It is send as form data
Code: Select all
put base64Encode(pImageData) into tFile
put libURLMultipartFormData (tForm,"image", tFile) into tError
if tError is not empty then
Answer tError
else
set the httpHeaders to line 1 of tForm
post line 2 to -1 of tForm to url tUrl
-
- VIP Livecode Opensource Backer
- Posts: 9850
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Using imgBB api in livecode
Well done, Mimu. Thanks for posting that.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 39
- Joined: Thu Jan 23, 2020 5:56 pm
Re: Using imgBB api in livecode
WOW! Thank you guys so much, I have been working on this for days and I appreciate you!
It does work!
It does work!