Why do we need it anyway?
Doesn’t it make more sense to uniquely the person using the phone rather than the phone itself?
I can whip out a solution in a couple of hours that would make having a unique userid with a simple PHP and MySQL database.
The reason why? because it’s there and its convenient.
So I had a brain fart, er. Epiphany today. Why not write my own…
So a couple of hours later, here’s what I’ve got.
I setup a PHP/MySQL server that will generate a unique ID with a provided AppID. I suggest using the typical com.yourdomain.appname as the appID.
http://omnigeekmedia.com/api/getuid.php?appid=com.yourdomain.appname
It returns a JSON structure on success that contains the uniqueID
Now on the Lua side, you need a little bit of code to make it work. Here’s where I’m at, but I have an error. Maybe someone can help me figure out my problem:
getuid.lua
module(..., package.seeall)
local http = require("socket.http")
local json = require("json")
function getuid(appid)
local r, e
local result
print("appid", appid)
r, e = http.request("http://omnigeekmedia.com/api/getuid.php?appid=" .. appid)
if e == 200 then
result = json\_decode(r)
return result.uid
end
return nil,result.message
end
And my main.lua:
local getuid = require("getuid").getuid()
local AppID = "com.omnigeekmedia.testapp"
guid = getuid(AppID)
print(guid)
The error I’m getting is that appid is nil when the function calls, but I’m clearly passing the AppID in.
The code inside the function works when appid is not nil.
Thoughts?
Anyone want to test it?
[import]uid: 19626 topic_id: 24499 reply_id: 99236[/import]