I need to integrate SMS for different events i.e on customer registration, new order placed, order status change, etc in magento with http sms api provided by sms provider. Please share if anyone have it. I want it to be customized and dont want to use any extension for it.
For Sms you need to purchase sms gateway .they provide their own curl type
api like www.textlocal.com
and api code like
$token="some message";
$username = urlencode($email_id);
$hash = urlencode($secretecode); // Get this when logged in at https://control.txtlocal.co.uk/docs/
// Message details
$numbers = urlencode($mobile_no);
$sender = urlencode('Textlocal');
$message = rawurlencode('Your activation code is :'.$token);
$data = 'username=' . $username . '&hash=' . $hash
. '&numbers=' . $numbers . "&sender=" . $sender . "&message=" . $message;
// Send the GET request with cURL
$ch = curl_init('https://api.txtlocal.com/send/?' . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Related
Dear stackoverflow community,
Recently PayPal contacted me to upgrade my 'old-style' CodeIgniter e-commerce cart (an old standard paypal gateway with a simple form to related paypal endpoint) to a solution with access token and client_id + secret. I used omnipay-paypal, following a guide like this:
https://artisansweb.net/paypal-payment-gateway-integration-in-php-using-paypal-rest-api/
And everything seems working fine, but with old standard cart I used a notifyUrl to send payment post data to a controller that made something like this:
foreach ($_POST as $key => $value) {
$request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}
$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 120);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
If that $response is VERIFIED, I enable related order for delivery (paid).
Issue is that notifyUrl isn't triggered at all with Omnipay and this avoids to fit the shoe.
I tried to setup notifyUrl parameter on purchase, completePurchase method, but nothing to do: no call is sent after payment confirmation and no payment data in the related $_POST object.
Someone could give me some hint or help?
I tried to force the notifyUrl in any possible way, but after transaction is complete and payment confirmed, the notifyUrl is not receiving the expected data with post.
Been using socialite for quite a while now and i'm wondering if there is any built-in method that allows me to retrieve a user repositories.
I'm familiar with the list on method offered on laravel website.
Any idea how to fetch the Repos given the user token ?
I found another to do that . Find the code below :
In the callback function i added a function that uses curl to fetch repos
public function handleProviderCallback()
{
$user = Socialite::driver('github')->user();
$this->getUserRepos($user);
}
The Get Repos function is as below :
private function getUserRepos($user)
{
$name=$user->getNickname();
$token=$user->token;
// We generate the url for curl
$curl_url = 'https://api.github.com/users/' .$name. '/repos';
// We generate the header part for the token
$curl_token_auth = 'Authorization: token ' . $token;
// We make the actuall curl initialization
$ch = curl_init($curl_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// We set the right headers: any user agent type, and then the custom token header part that we generated
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Awesome-Octocat-App', $curl_token_auth));
// We execute the curl
$output = curl_exec($ch);
// And we make sure we close the curl
curl_close($ch);
// Then we decode the output and we could do whatever we want with it
$output = json_decode($output);
foreach ($output as $repo) {
print '' . $repo->name . '<br />';
}
}
And it works swiftly .
I am new to php and building my first project.
I am creating a auto response email which will be sent to user after form submission.
The auto response email need to have content as follows,
Logo image
Thank you for contacting us.
Here you can view our case study.(need to link pdf file to view**)
I manage to get text. but not able to add image and hyperlink.
tried using variable to store image url but code is visible instead of an image.
i request if someone Please guide me.to solve this.
<?php
$to = $_POST['email'];
$from = "info#company.com";
$headers = "From: company";
$subject = "Thank you for contacting us.";
//$img='<img src="http://www.http://company.com/images/logo.jpg"/>';
$linkedin='Linkedin';
$twitter='Twitter';
$message=
"Dear ".$firstname." Thank you for contacting us.
Here you can view our case study.
www.company.com/data/casestudy.pdf
www.company.com | info#company.com | Linkedin | Twitter
";
$mailsent = mail($to, $subject, $message, $headers);
?>
First, In $header add content type to HTML
$headers .= "Content-type:text/html;charset=UTF-8";
http://php.net/manual/en/function.mail.php
This will set mail Content type to HTML, Now you can add all Tags and link of HTML without using variables, So full code will be like this
<?php
$to = $_POST['email'];
$from = "info#company.com";
$headers = "From: company";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$subject = "Thank you for contacting us.";
$message="<img src='http://company.com/images/logo.jpg'/>
<br/>Dear ".$firstname." Thank you for contacting us.
Here you can view our case study.
<a href='www.example.com'>File Name </a>
www.company.com | info#company.com |<a href='www.linkedin.com'>Linkedin</a> |<a href='twitter.com'> Twitter</a>
";
$mailsent = mail($to, $subject, $message, $headers); ?>
And don't get confused in single-quotes and double-quotes used here also i assume your $firstname has some value.
I would like to get the order details using observer ,
Once i get the order it will sent order details to my test email , but i can not able to get the order details.
please check the code which i tried to get the order details, Can someone let me know how can i get the order details , thanks.
public function postdata($observer) {
$to = 'testmail#gmail.com';
$subject = 'Mail after Sale order place.';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = 'This is my first Magento Observer After Sale order place';
mail($to, $subject, $message, $headers);
$order = $observer->getEvent()->getOrder();
$order_message = $order;
foreach($order as $ok => $ov) {
$order_message .= $ok. " => " .$ov;
}
mail($to, $subject, $message, $headers);
}
}
You can configure Magento to send you a copy of the order confirmation email that gets sent to the customer. If that is sufficient for your needs, this previously answered question will do the trick.
Use sale_order_save_after event to get the order details after place the order.
I am trying to send a text message via the following in PHP Codeigniter.
If I send an email to the same "###########vtext.com" from my gmail client, I receive the text message.
If I use the same code below but substitute my gmail account, I receive the message via email.
However, I cannot seem to trigger a text message sent to me via the code below.
I am thinking it may have something to do with a spam filter somewhere within the phone service.
Any suggestions, or else a free workaround for sending SMS via PHP/Codeigniter? Thanks!
public function textMe()
{
$this->load->library('email');
$this->email->to('###########vtext.com'); [number edited out]
$this->email->from('Notify#test.org','Test');
$this->email->subject("Test Subject");
$this->email->message('Test Message');
$this->email->send();
echo $this->email->print_debugger();
}
Codeigniter helper is useful in this case. Helper function will be available wherever needed. Save below file in Application/Heplers/sendsms_helper.php
/*Start sendsms_helper.php file */
function sendsms($number, $message_body, $return = '0'){
$sender = 'SEDEMO'; // Need to change
$smsGatewayUrl = 'http://springedge.com';
$apikey = '62q3z3hs49xxxxxx'; // Change
$textmessage = urlencode($textmessage);
$api_element = '/api/web/send/';
$api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.
'&message='.$textmessage;
$smsgatewaydata = $smsGatewayUrl.$api_params;
$url = $smsgatewaydata;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
if(!$output){
$output = file_get_contents($smsgatewaydata);
}
if($return == '1'){
return $output;
}else{
echo "Sent";
}
}
/* * End sendsms_helper.php file */
** Use:**
Load sendsms helper as $this->load->helper('sendsms_helper');
Call sendsms function Ex. sendsms( '919918xxxxxx', 'test message' );