@coslad: here is the kernel code snipped to send GCM with VB6. After the last (every) line you can handle the answer of the requests.
Your GoogleAppID and your SENDER_ID should be declared as "const" before.
As parameter you can give the "Msg" and the "device_id" from the smartphone.
Is it possible to write a desktop-computer server app that can receive messages from a smartphone that has no own IP ?
CODE:
URL = "android.googleapis.com"
URL_Objekt = "gcm/send"
hInternetOpen = InternetOpen(App.EXEName, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hInternetConnect = InternetConnect(hInternetOpen, URL, INTERNET_DEFAULT_HTTP_PORT, vbNullString, "HTTP/1.1", INTERNET_SERVICE_HTTP, 0, 0)
hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "POST", URL_Objekt, "HTTP/1.1", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
'add 3 Headers
sHeader = "Authorization: Key=" & GoogleAppID & vbCrLf
bRet = HttpAddRequestHeaders(hHttpOpenRequest, sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
sHeader = "Content-Type: application/x-www-form-urlencoded;charset=ISO 8859-1" & vbcrlf
bRet = HttpAddRequestHeaders(hHttpOpenRequest, sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
sHeader = "Sender: Key=" & SENDER_ID & vbCrLf
bRet = HttpAddRequestHeaders(hHttpOpenRequest, sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
sPostData = "collapse_key=score_update&time_to_live=108" & _
"&delay_while_idle=1" & _
"&data.message=" & Msg & _
"&data.time=" & mNow & _
"®istration_id=" & device_id
dwTimeOut = 10000 '10 Sekunden
bRet = InternetSetOption(hHttpOpenRequest, INTERNET_OPTION_CONNECT_TIMEOUT, dwTimeOut, 4)
bRet = InternetSetOption(hHttpOpenRequest, INTERNET_OPTION_RECEIVE_TIMEOUT, dwTimeOut, 4)
bRet = InternetSetOption(hHttpOpenRequest, INTERNET_OPTION_SEND_TIMEOUT, dwTimeOut, 4)
bRet = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, sPostData, Len(sPostData))
@Beja
Decoding Radio-Data is one of many more featrures of my Windows-Application. To send an alarm-message to a spartphone and send back the status or locations should only be an additional way to inform the people.