QB64 Phoenix Edition
Kanye REST - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Kanye REST (/showthread.php?tid=1249)



Kanye REST - SpriggsySpriggs - 12-08-2022

Below is some code to grab a random Kanye "Ye" West quote:

Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only
$Unstable:Http

Dim As Long connection: connection = OpenClient("HTTP:https://api.kanye.rest/")
If connection <> 0 And StatusCode(connection) = 200 Then
    Dim As String buf, outbuf
    While Not EOF(connection)
        Get connection, , buf
        outbuf = outbuf + buf
    Wend
    outbuf = Mid$(outbuf, 11)
    outbuf = Mid$(outbuf, 1, Len(outbuf) - 2)
    Print outbuf
    Print: Print "-Kanye West"
End If



RE: Kanye REST - SMcNeill - 12-08-2022

Note: This needs the latest GitHub build to run.  It won't work in version 3.4.1, just FYI.


RE: Kanye REST - Jack - 12-08-2022

you can get the quotes from https://github.com/ajzbc/kanye.rest/blob/master/quotes.json


RE: Kanye REST - SpriggsySpriggs - 12-08-2022

Yeah, I'm just trying to show how easy it is to use the new features in QB64pe


RE: Kanye REST - Jack - 12-08-2022

in the early Mac computer there was a program available that would at random times pop-up Bullwinkle the moose an say something silly/funny
see https://en.wikipedia.org/wiki/Bullwinkle_J._Moose
https://www.wired.com/2001/08/hey-mac-the-moose-is-loose/


RE: Kanye REST - bplus - 12-09-2022

Time to get out yer shovels when the moose is loose. -Kenye


RE: Kanye REST - mnrvovrfc - 12-09-2022

Requires the file "quotes.json". If it's in the same format it doesn't matter who the speaker was, does it?

Code: (Select All)
$CONSOLE:ONLY
dim as long ff, ll, l, ts

ts = (val(mid$(time$, 4, 2)) mod 2) * 60 + val(right$(time$, 2))

afile$ = "quotes.json"
ff = freefile
open afile$ for input as ff
do until eof(ff)
    line input #ff, aline$
    if aline$ = "[" then
        ll = 0
    elseif aline$ = "]" then
        exit do
    else
        ll = ll + 1
    end if
loop
close ff

redim sf$(1 to ll)
ff = freefile
open afile$ for input as ff
do until eof(ff)
    line input #ff, aline$
    if aline$ = "[" then
        l = 0
    elseif aline$ = "]" then
        exit do
    else
        l = l + 1
        aline$ = _trim$(aline$)
        if l = ll then
            sf$(l) = mid$(aline$, 2, len(aline$) - 2)
        else
            sf$(l) = mid$(aline$, 2, len(aline$) - 3)
        end if
    end if
loop
close ff

print sf$(ts)
print "- Kanye West"
system



RE: Kanye REST - SpriggsySpriggs - 12-09-2022

Yep, you definitely can read a JSON file in QB64pe


RE: Kanye REST - grymmjack - 04-28-2023

oh i get it. Kanye REST - Kanye WEST.

CLEVER. Also thanks for sharing.