Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with PostSync?

What am I doing wrong?

Im trying to keep this simple. Comment or use the Community Chat to ask me questions!

local Data={
token = "adgdrharhartjartjajtrjartjartj",
user = "atjhartjrjsryjsyjtdyjsdt",
title= "Testing",
message= "HERRO"
}
game:GetService("HttpService"):PostAsync("Website",Data)

4 comments

0

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).

0

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.

0

PHP isn't required, you just need an HTTP server. Node.JS, Ruby, ASP.net, Python, even C++ are all alternatives

0

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.

1 answer

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)
-- Yields a variable myTable table that looks like {"a", "b", "c"}

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
--[[
	Theres a few different types..
		ApplicationJson
		ApplicationXml
		ApplicationUrlEncoded
		TextPlain
		TextXml

	(Default is Enum.HttpContentType.ApplicationJson, highly recommended to add anyways though)
]]--

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.