I'm using Laravel-4-Nexmo package to send sms but the message is encoded on delivery .
$receiverNumber = "xxxxxxxxxxx"
$message = "hi from nexmo ? ";
$options = array( 'status-report-req' => 1 );
$Nexmo = Nexmo::sendSMS('me', $receiverNumber , $message , $options);
and received message looks like this :
hi+from+nexmo+%3F+
I would like to receive as
hi from nexmo ?
I look forward to see what could be the solution
Probably the mentioned package does not encode the given message so you should use urlencode($yourString) before using the pacckage
I do not know what was wrong with my code above, and I decided to use similar package and it works now. you can find the package here https://github.com/Artistan/nexmo
Related
I got an issue with HMAC.
I have to sign a form before sending it to a bank.
They only provide an example in PHP in their documentation.
I have a hex key to sign my data (e.g. FCEBA61A884A938E7E7FE4F5C68AA7F4A349768EE5957DDFBE99C1D05A09CBACF1FCF0A7084CB2E4CBA95193176C4395DE7F39EA9DBEBEF0907D77192AAE3E8A).
In the PHP exemple, they do this with the key before signing the data:
$key = "FCEBA61A884A938E7E7FE4F5C68AA7F4A349768EE5957DDFBE99C1D05A09CBACF1FCF0A7084CB2E4CBA95193176C4395DE7F39EA9DBEBEF0907D77192AAE3E8A";
$message = "param1=a¶m2=b";
$binKey = pack('H*', $key);
$signature = hash_hmac('sha512', $msg, $binKey);
echo $signature;
// => a3efb70368bee502ea57a1a4708cac8912a5172075ea8dec2de2770dfbb4c8fb587f03fdadc0ca4f9e1bb024cfda12866295b259f5fb4df2fe14d960874a68ab
I don't understand why they pack the key and if I should do something similar with my key.
I did the following in my Ruby code:
key = "FCEBA61A884A938E7E7FE4F5C68AA7F4A349768EE5957DDFBE99C1D05A09CBACF1FCF0A7084CB2E4CBA95193176C4395DE7F39EA9DBEBEF0907D77192AAE3E8A"
message = "param1=a¶m2=b"
digest = OpenSSL::Digest.new('sha512')
signature = OpenSSL::HMAC.hexdigest(digest, key, message)
puts signature
# => d817611845246640d1224a0874bf60fed0956a367aa3069b7947cbec56903bb5d8c54df170f5504c586dad55e4f879c70cf1a40526cfc9f35411195822c535ed
You need to do this in Ruby:
hash = OpenSSL::HMAC.hexdigest(digest, [key].pack('H*'), message)
The real issue here is that your PHP code uses two variable names for the message. You set $message, then use $msg, which means you're computing the hash for an undefined variable.
The packing of the hex representation of the key back into a binary form is the bit you're missing.
See this post for example: https://blog.bigbinary.com/2011/07/20/ruby-pack-unpack.html
You'll want something like this:
signature = OpenSSL::HMAC.hexdigest(digest, key.pack('H'), message)
I'm using this in my project:
bin_key = Array(keyTest).pack 'H*'
#hmac = OpenSSL::HMAC.hexdigest("SHA512", bin_key, msg).upcase
This works fine for me.
Hello I am new to Magento (Magento 2.1) My problem is that when any message like sign up successfully or order successfully it is displayed word joining with + sign instead of space. like :
please help.
Provide the code where you concatenate the message. The message should be
$this->messageManager->addError( __('This is your error message.') );
//or
$this->messageManager->addError( __('Invalid %s or %s', 'login', 'password') );
//or replace with variables
I have done my push notification using laravel. But notifications are overlapping on my mobile. How to show the count and logo.It should not overlap
Hi i got solution for this issue. i have added the 'notid' attribute in my message parameters. here is my code
$message = PushNotification::Message($msg,array('message'=> $msg,
'title'=>$title,'notId' =>rand(10,100),'locKey' => 'localized key','locArgs' => array('localized args','localized args'),
)
);
Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg
Here is the PHP code that I use:
$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
$date = date('Y-m-d');
$subject = "Tack för Ert köp! / Thank you for your order!";
$headerFields = array(
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
"From: {$to}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
mail($to, $subject, $message, implode("\r\n", $headerFields));
So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?
You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.
Try passing null as the second argument instead.
Used the following code.
$mail = new Zend_Mail();
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
This is the part i wrote.
I am getting proper html in $message. The $ variable used above are from retrieved post value. The mail which I am receiving contains contents like :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
in the starting part rest all the mail content are fine.Thanks in advance
From myunderstanding,i conclude with this part utf-8 adding in your code
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
Hope this helps you.