API Request to Send a message to a Group
Request URL
https://yourgrupowebsiteaddress/api_request/
Request body
Field | Description/Values | Required/Optional |
---|---|---|
api_secret_key | Your Grupo API Secret Key. For API Secret Key, Click on Menu > Select Settings > Select General Settings > Find API Secret Key | Required |
add | message | Required |
group | Group ID/Slug of the group | Required |
sender | Sender Username/Email Address | Required |
message | Message Content | Required |
file_attachments | File Attachment | Optional |
gif_url | GIF Image URL [tenor.com | gfycat.com | giphy.com] | Optional |
Response Body
KEY | Description/Values |
---|---|
success | This returns true on success and false on failure. |
error_message | Returns a relevant error message |
error_key | This method returns the error key associated with the error |
Example PHP Code
<?php
$grupo_web_address = 'https://yourgrupowebsiteaddress';
$post_fields=[
'api_secret_key' => 'Your_Grupo_API_Secret_Key',
'add' => 'message',
'group' => 'Group ID/Group Slug',
'sender' => 'username/email_address',
'message' => 'Message Content',
'file_attachments' => 'file_path',
'gif_url' => '',
];
$api_request_url = rtrim($grupo_web_address, '/').'/'.'api_request/';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $api_request_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0'
));
if (isset($post_fields['file_attachments']) && !empty($post_fields['file_attachments'])) {
$post_fields['file_attachments'] = new CURLFILE($post_fields['file_attachments']);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($curl);
curl_close($curl);
if (!empty($response)) {
$response = json_decode($response);
if (!empty($response)) {
if (isset($response->error_message)) {
echo $response->error_message;
} else {
echo "Message Sent Successfully";
}
}
}
?>