This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Help me !
#1
-------------------
http = require('socket.http')
require('socket.http')

local anh = http.request {
  url = "api.speedsms.vn/index.php/user/info",
  headers = { authentication = "Basic " .. (mime.b64("kuDkYXtIBidDjCRmN8z_Yt9U12Dbs8TZ:x")) }
  }
alert('value is:'..anh)
---------------------
It reported error value "he" is "a nil value"
Am I wrong in that? Any wrong structure? Please help me !
Thank so much everyone.  Heart
Reply
#2
url must start with http://, also run your request like this so you can see full server response in Logs tab:
Code:
http = require('socket.http')
log(http.request {
  url = "api.speedsms.vn/index.php/user/info",
  headers = { authentication = "Basic " .. (mime.b64("kuDkYXtIBidDjCRmN8z_Yt9U12Dbs8TZ:x")) }
})
Reply
#3
Oh, thank so much admin !
If the value of his "anh" is Json, how to get that value "balance number" on alert or send sms to the user?
---------------
{ "status": "success", "code": "00", "data": { "email": "your email address", "balance": "balance number", "currency": "VND" } }
---------------
local anh = http.request {
  url = "http://api.speedsms.vn/index.php/user/info",
  headers = { Authorization = "Basic " .. (mime.b64("kuDkYXtIBidDjCRmN8z_Yt9U12Dbs8TZ:x")) }
}
--------------------
Thank admin with this help!
Reply
#4
Help me ! top top
Reply
#5
Code:
require('json')
http = require('socket.http')
resp = {}
res = http.request({
  url = "http://api.speedsms.vn/index.php/user/info",
  headers = { authentication = "Basic " .. (mime.b64("kuDkYXtIBidDjCRmN8z_Yt9U12Dbs8TZ:x")) },
  sink = ltn12.sink.table(resp)
})
if res then
  resp = table.concat(resp)
  resp = json.pdecode(resp)
  if resp then
    log(resp.data.balance)
  end
end
Reply
#6
Hi,

Should that not be log(resp.data.balance)?

BR,

Erwin
Reply
#7
Yes, thanks Erwin!
Reply
#8
Thank so much admin and Erwin van der Zwart!
I was successful !
Smile
Reply


Forum Jump: