Update giphy.lua

This commit is contained in:
Yago 2015-02-27 21:31:14 +01:00
parent 84b7062aed
commit 5c38c4842f

View File

@ -15,7 +15,10 @@ function get_random_top()
end end
function search(text) function search(text)
local res, code = http.request(BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY) text = URL.escape(text)
local url = BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY
print(url)
local res, code = http.request(url)
if code ~= 200 then return nil end if code ~= 200 then return nil end
local images = json:decode(res).data local images = json:decode(res).data
if #images == 0 then return nil end -- No images if #images == 0 then return nil end -- No images