Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with PostSync?

Asked by
Dr_Doge 100
8 years ago

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)
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). funyun 958 — 8y
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. P100D 590 — 8y
0
PHP isn't required, you just need an HTTP server. Node.JS, Ruby, ASP.net, Python, even C++ are all alternatives BlueTaslem 18071 — 8y
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. BlueTaslem 18071 — 8y

1 answer

Log in to vote
3
Answered by
Im_Nick 30
8 years ago

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

Answer this question