33
44load "webview.ring"
55load "jsonlib.ring"
6- load "internetlib .ring"
6+ load "libcurl .ring"
77
88# Global variable to hold the WebView instance .
99oWebVi ew = NULL
@@ -42,9 +42,8 @@ func loadQuoteHTML()
4242 < title >Avatar Quotes Generator < /tit le >
4343 < meta charset = "UTF-8" >
4444 < meta name = "viewport" conte nt = "width=device-width, initial-scale=1.0" >
45- < link rel = "stylesheet" hr ef = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1 /css/all.min.css" >
45+ < link rel = "stylesheet" hr ef = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0 /css/all.min.css" >
4646 < sty le >
47- @ import url ('htt ps ://fonts .googleapis .com /css2 ?family =Inter :wg ht @ 400 ;500 ;700 &family =Fira +Code :wght @ 400 ;500 &display =swap ');
4847 :ro ot {
4948 --bg -color : #000000 ;
5049 --panel -bg : rgba (30 , 30 , 32 , 0.6 );
@@ -199,7 +198,7 @@ func handleFetchQuote(id, req)
199198 cErrorMessa ge = ""
200199
201200 try
202- cRespon se = download (cQuotesA PI ) # Fetch data from the Avatar Quotes API .
201+ cRespon se = request (cQuotesA PI ) # Fetch data from the Avatar Quotes API .
203202 aJs on = json2list (cRespon se )["quotes" ][1 ] # Parse the JSON response .
204203 # Structure the result as a list (arr ay ) for JSON conversion .
205204 aResu lt = [
@@ -217,4 +216,19 @@ func handleFetchQuote(id, req)
217216 if bErr or
218217 # If an error occurr ed , return an error messa ge .
219218 oWebView .wreturn(id, WEBVIEW_ERROR_ OK , list2json ([:err or = cErrorMessa ge ]))
220- ok
219+ ok
220+
221+ # Function to make a HTTP request using libcurl
222+ func request (u rl )
223+ cu rl = curl_easy_init ()
224+
225+ curl_easy_setopt (cu rl , CURLOPT_USERAGE NT , "RingLibCurl" )
226+ curl_easy_setopt (cu rl , CURLOPT_FOLLOWLOCATI ON , 1 )
227+ curl_easy_setopt (cu rl , CURLOPT_U RL , u rl )
228+ curl_easy_setopt (cu rl , CURLOPT_SSL_VERIFYPE ER , false )
229+
230+ cOutp ut = curl_easy_perform_silent (cu rl )
231+
232+ curl_easy_cleanup (cu rl )
233+
234+ return cOutp ut
0 commit comments