Is it possible to send a keyboard without sending text or a message at telegram - telegram-bot

I try to send and delete the message but not working
if($new = $bot->sendMessage([
'chat_id' => $call_chat_id,
'text' => ' ',
'parse_mode' => 'HTML',
'reply_markup' => $choose,
])){
$bot->deleteMessage([
'chat_id' => $chat_id,
'message_id' => $new['message_id']
]);
}
am using Telegram-bot-simple

No there is no way to send keyboard without sending a message

Related

Mollie applicationfee's

for a customer I need to charge an applicationFee for each order that has been processed on their site from the sub customers. The whole code is working with authentication and everything.
But from the moment I'm adding:
'applicationFee' => $applicationFee
to the call I receive this error:
Error executing API call (422: Unprocessable Entity): Unable to process application request for this account. Documentation: https://docs.mollie.com/guides/handling-errors"
The content of "$applicationFee" is correct, that I was able to check already.
The $shop_mollie_data->profile_id containts the different websiteprofileId's found on the Mollie dashboard.
$provider = new MollieConnectProvider($request, $clientId, $clientSecret, $redirectUrl);
$newAccessToken = $provider->getRefreshTokenResponse($shop_mollie_data->refresh_token);
$mollie = new MollieApiClient();
$mollie->setAccessToken($newAccessToken['access_token']);
$payment = $mollie->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => (string) (sprintf("%.2f", $order_total))
],
'description' => ucfirst($shop->name) . ' - Order #' . $order_nm,
'webhookUrl' => $url_callback,
'redirectUrl' => $url_success,
'method' => 'bancontact',
'locale' => $language_id,
'metadata' => [
"order_id" => $ref,
"shop id" => $shop->id
],
'profileId' => $shop_mollie_data->profile_id,
'testmode' => true,
'applicationFee' => $applicationFee
]);

Slack API: How to reply for an attachment action?

I've created an integration with Slack as a WebHook APP. The code is to send a message to a slack channel, using the chat.postMessage method, with some attachment actions, then when the user click the action button, I send him a success message. I'm trying to do something like this:
https://api.slack.com/img/api/message_guidelines/Example_6.gif
The problem is when I try to send the success message. Slack is receiving only the text part of the answer. Here is the code:
$message = 'Pre-text message';
$attachments = array(
array(
"title" => 'Title message',
"author_name" => 'My name',
"author_link" => 'https://www.facebook.com/',
"author_icon" => 'https://graph.facebook.com/v2.6/picture',
"image_url" => 'https://i.scdn.co/image',
),
);
$answer = array(
'text' => $message,
'attachments' => json_encode($attachments)
)
How can I do to Slack show the answer with the attachment part as shown in the image above? If I comment the text part on $answer, Slack show an error to user ('Oh no, something went wrong. Please try that again.'). Many thanks for any help.
I found the solution. Posting here to help somebody with the same problem. When you posting a message, should json_encode the attachment part, but when posting the attachment action answer, is not necessary. Here is the solution:
$message = 'Pre-text message';
$attachments = array(
array(
"title" => 'Title message',
"author_name" => 'My name',
"author_link" => 'https://www.facebook.com/',
"author_icon" => 'https://graph.facebook.com/v2.6/picture',
"image_url" => 'https://i.scdn.co/image',
),
);
$answer = array(
'text' => $message,
'attachments' => $attachments
)

Using SendCloud with 'X-SMTPAPI' in Rails

I hope this post will help someone.I need to use SendCloud to send emails through smtp.At the begin i add header in ActionMailer:
headers["X-SMTPAPI"] = JSON.dump({"to" => emails, "sub" => {"%name%" => names}})
But it can't work, and i also can't receiver the return error code through Rails.Then i find the way through communication with their support:
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}}))
But it also can't work correctly.Then i compare the generated headers["X-SMTPAPI"] with the sent headers["X-SMTPAPI"], and found Rails insert '\n' in it for format.In the end, Mail gem convert the '\n':
def encode_crlf(value)
value.gsub!(CR, CR_ENCODED)
value.gsub!(LF, LF_ENCODED)
value
end
So, if i want it's success, i need to do like this:
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}})).gsub!(/\n/,'')
Wow, i can send 'x-smtpapi' header in Rails successfully!
I solve it by encode and replacing '\n':
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}})).gsub!(/\n/,'')

Mandrill's UNSUB merge tag not getting parsed

I'm trying to make it so when someone clicks on the unsubscribe link in an email sent via the Mandrill API (using PHP) it works as described in: http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-
The *|UNSUB|* merge tag is not getting parsed. It just comes through in the the body of the email received.
Near the end of the message content ($message_content) I have:
Click here to unsubscribe.
In Gmail, the link is: Click here to unsubscribe.
(NOT a valid HREF, so Gmail just ignores the anchor tag)
In Outlook 2010 the link is: Click here to unsubscribe.
(Not a valid HREF)
Is there some merge_vars parameter I should add to the headers?
http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content- mentions them, but I can't find what the parameter should be for the UNSUB merge tag.
$mandrill = new Mandrill($mandrill_api_key);
$message = array(
'html' => $message_content,
'subject' => $subject,
'from_email' => 'me#mydomain.com',
'from_name' => 'MY NAME',
'to' => $to_list,
'headers' => array('Reply-To' => 'me#mydomain.com'),
'important' => false,
'track_opens' => 1,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => 0,
'view_content_link' => 1,
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'global_merge_vars' => array(
array(
'unsub' => 'unsub'
)
),
);
What step am I missing?
TIA!
The problem was the URL was missing a slash (http:/mydomain...)
This was caused by TinyMCE converting URLs. I added convert_urls: false to the tinymce.init and that solved my problem.
Kudos to Mandrill Support for helping me identify the problem.

How can I sent relevant email by using Amazon SES?

I am using Amazon SES server for sending notifications emails to my users. I have verified email and verified domain. So SES_Client is sending emails successfully.
Here is my code:
public function send($subject, $recipients, $body, $senderName){
$response = $this->SESClient->send_email(
$senderName.'-noreply#example.com',
array(
'ToAddresses' => $recipients
),
array(
'Subject' => array(
'Data' => $subject,
'Charset' => 'UTF-8'
),
'Body' => array(
'Text' => array(
'Data' => $body,
'Charset' => 'UTF-8'
),
'Html' => array(
'Data' => $body,
'Charset' => 'UTF-8'
)
)
)
);
return $response->isOK();
}
Problem:
How can I pass parameters values in email text that are belongs to individual recipient in recipients array?
Is there a way at amazon server where I can create queue of my recipients and when SES server will send my email. It will replace all parameters values that belongs to each recipient.
The ToAddresses field should be an array.
Is there a way at amazon server where I can create queue of my recipients and when SES server will send my email. It will replace all parameters values that belongs to each recipient.
No, AWS and the SES service does not currently support this.