Http get not working.

Hello Community,
I have a website I need to call and read data from their api. I need to input the up to the api, and get it’s plain text response. I’m on my phone so I don’t have the code, but I used the default Gmod wiki example. No errors. Please help.

[lua]
local TheReturnedHTML = “”
http.Fetch( “http://google.com”,
function( body, len, headers, code )
TheReturnedHTML = body
print(TheReturnedHTML)
end,
function( error )
print (error)
end
)
end
[/lua]

Works fine, if you are using it in a early hook such as initpostent then you need to have it on a 1-3 second timer otherwise the HTTP get will fail.

Example ? And thnx.

[editline]24th August 2015[/editline]

How do I hook it. I am using the player join hook.

[editline]24th August 2015[/editline]

I assume any hook will work. Would it be a 3 Second repeater timer, checking if the returned is not nil?

I’ve recently noticed that http.Fetch is having difficulties working on Linux.
What’s your OS?

Im using linux to fetch codes from web and it works fine for me.

For what do you need to fetch site every player join? Record them visiting?

I am using Windows 8.1.

[editline]25th August 2015[/editline]

Funny you mention that, but no. It was just for fun. On player join, the lua would snag the user’s avatar url from steam, pop it into google images, and get google’s best guess for it, then it would tell the player what is is. (Abeit a MLGer or a FNAF infectite.) Of course it could be completely wrong, which is still funny.

@All
I found the problem. Aparrently GMOD doesn’t like certain hooks. I was using the player connect hook, so now I am using the player spawn hook with no problems. Thread solved.