06-05-2018, 02:33 AM
Has anyone tried to implement the Groupme API to receive data posted in a group chat? https://dev.groupme.com/tutorials/push
I was able to create the code needed to post a message into a group chat, but I'd like to also be able to have no posts pushed to me.
the code I found in the forum post a message was simple and worked perfectly (thanks)
---------------------------
Http Host.Connect("api.groupme.com" 0 0 443)
Host.PostAdd("bot_id" "xxxxxxxxxxxxxxxxxxxxxxxx")
Host.PostAdd("text" F"{text}")
str r8
if(!Host.PostFormData("/v3/bots/post" 0 r8 "" 0 0 INTERNET_FLAG_SECURE)) end "failed"
-----------------------------
But I can't understand how to make the push work.
Step 1 of the instructions is simply to send a post with this data to https://push.groupme.com/faye
[
{
"channel":"/meta/handshake",
"version":"1.0",
"supportedConnectionTypes":["long-polling"],
"id":"1"
}
]
The code I tried was this:
str r8
str r9
str d1
d1="[''long-polling'']" ;;inside [] are two single quotes
Http Host.Connect("push.groupme.com" 0 0 443)
str headers
lpstr sh="Content-Type: application/json"
if(empty(headers)) headers=sh
Host.PostAdd("channel" "/meta/handshake")
Host.PostAdd("version" "1.0")
Host.PostAdd("supportedConnectionTypes" F"{d1}")
Host.PostAdd("id" "1")
if(!Host.PostFormData("faye" 0 r8 headers 0 0 INTERNET_FLAG_SECURE r9)) end "failed"
out r8
out r9
The response was this:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Date: Tue, 05 Jun 2018 02:10:45 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Any help to correctly create this POST would really appreciated. I can probably figure out the remaining steps but not 100% about that
I was able to create the code needed to post a message into a group chat, but I'd like to also be able to have no posts pushed to me.
the code I found in the forum post a message was simple and worked perfectly (thanks)
---------------------------
Http Host.Connect("api.groupme.com" 0 0 443)
Host.PostAdd("bot_id" "xxxxxxxxxxxxxxxxxxxxxxxx")
Host.PostAdd("text" F"{text}")
str r8
if(!Host.PostFormData("/v3/bots/post" 0 r8 "" 0 0 INTERNET_FLAG_SECURE)) end "failed"
-----------------------------
But I can't understand how to make the push work.
Step 1 of the instructions is simply to send a post with this data to https://push.groupme.com/faye
[
{
"channel":"/meta/handshake",
"version":"1.0",
"supportedConnectionTypes":["long-polling"],
"id":"1"
}
]
The code I tried was this:
str r8
str r9
str d1
d1="[''long-polling'']" ;;inside [] are two single quotes
Http Host.Connect("push.groupme.com" 0 0 443)
str headers
lpstr sh="Content-Type: application/json"
if(empty(headers)) headers=sh
Host.PostAdd("channel" "/meta/handshake")
Host.PostAdd("version" "1.0")
Host.PostAdd("supportedConnectionTypes" F"{d1}")
Host.PostAdd("id" "1")
if(!Host.PostFormData("faye" 0 r8 headers 0 0 INTERNET_FLAG_SECURE r9)) end "failed"
out r8
out r9
The response was this:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Date: Tue, 05 Jun 2018 02:10:45 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Any help to correctly create this POST would really appreciated. I can probably figure out the remaining steps but not 100% about that