A few important points I need to make.
Use JSON and :PostAsync() requires 3 arguments.
ALSO.. You need to understand PHP, JSON, HTML5 before anything.
http://php.net/manual/en/intro-whatis.php
As well you need a webserver that is encoded in PHP and MySQL. (Must be HTTP/SSL enabled)
Links:
http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONDecode
http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONEncode
http://wiki.roblox.com/index.php?title=API:Class/HttpService/PostAsync
http://prntscr.com/altjnt
JSONDecode:
If you have something which has been JSON encoded, such as ["a","b","c"], you can use this method to decode it into a Lua table.
myJSON = [=[["a","b","c"]]=]
hs = game:GetService("HttpService")
myTable = hs:JSONDecode(myJSON)
JSONEncode:
HttpService = game:GetService("HttpService")
mytab = {"a","b","c"}
print(HttpService:JSONEncode(mytab))
Now, your code.. Lets fix this up shall we? :D
local Http = game:GetService("HttpService")
local JSON_Type = Enum.HttpContentType.ApplicationJson
local Url = "www.example.com"
local Data = {
token = "abc";
user = "abcd";
title = "abcde";
message = "Hello!"
}
local JSON_String = Http:JSONEncode( Data )
local Returning_post = Http:PostAsync(Url, JSON_String, JSON_Type)
print(Returning_post)
4 comments
First off, before you'd do anything with PostAsync, you'd need to understand PHP, and you'd probably need a web server that has PHP and MySQL (and I think it has to be HTTPS/SSL enabled).
MySQL, HTTPS, and SSL are in no way requirements to use HTTP POST and HTTP GET methods. PHP, however, is required. I would ask OP to please tell us what this is supposed to do, how it isn't working, and where he's sending the post request.
PHP isn't required, you just need an HTTP server. Node.JS, Ruby, ASP.net, Python, even C++ are all alternatives
That said: If you don't have a server with a particular task in mind: you don't need HttpService. DataStores can be used for persistence and analytics of all data.