Replaced file_get_contents with curl+json_decode function