Sharing or sending message to whatsapp from a website using a link is simple as possible. In this article we will not use any package or third party tool to share the url or message to whatsapp. Whatsapp itself provide to share or send message using the url so in this article i will show you to share message from your site to whatsapp.
Whatsapp is most used social messaging app and we all want a button on our website to share the our product or contact to provider using whatsapp. So in this article we will cover it in a easy way so it will not take much time to implement.
Here is the url
Send or share a page from a website button to whatsapp
We can easily share a a page to whatsapp using below url
https://wa.me/?text=https://readerstacks.com
You can use it in your html as below
<a target="_blank" href='https://wa.me/?text=https://readerstacks.com'>Share to WhatsApp </a>
Send Message from a website button to whatsapp
We can easily open a chat window of a user using below url, you can directly hit in browser or can use in website
https://wa.me/phone_number_of_user
You can use it in your html as below
<a target="_blank" href='https://wa.me/phone_number_of_user'>Share to WhatsApp </a>
Let’s take an example Share/Send Message to WhatsApp in Laravel PHP
Step 1 : Create routes
Add appropriate routes to connect our URL to controller therefore open routes/web.php
and add below routes
<?php
use Illuminate\Support\Facades\Route;
use \App\Http\Controllers\PostController;
Route::get('/share-post',[PostController::class, 'share']);
Here we created one route only that means you can create it anywhere but we are using it only our demo purpose.
Step 2 : Create Controller
Now, create the controller as we have mentioned in routes is PostController
and also create three methods create
, store
and refreshCaptcha
so create a file in app\Http\Controllers\PostController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class PostController extends Controller
{
public function share()
{
return view('post.share-post');
}
}
Step 5 : Create view
We have create the controller and now we will create the view to show the button for sharing on social media
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Readerstacks Share/Send Message to WhatsApp in Laravel PHP </title>
<link href="//netdna.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.1/css/all.min.css" integrity="sha512-9my9Mb2+0YO+I4PUCSwUYO7sEK21Y0STBAiFEYoWtd2VzLEZZ4QARDrZ30hdM1GlioHJ8o8cWQiy8IAb1hy/Hg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body class="antialiased">
<div class="container">
<!-- main app container -->
<div class="readersack">
<div class="container">
<div class="row">
<div class="col-md-6 offset-md-3">
<h3> Share/Send Message to WhatsApp in Laravel PHP - Readerstacks</h3>
<div class="row">
<div class="col-12">
<a class="btn btn-success" target="_blank" href='https://wa.me/81XXXX912'>Send Message to WhatsApp </a>
<a class="btn btn-danger" target="_blank" href='https://wa.me/?text=https://readerstacks.com'>Share to WhatsApp </a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- credits -->
<div class="text-center">
<p>
<a href="#" target="_top"> Share/Send Message to WhatsApp in Laravel PHP - Readerstacks</a>
</p>
<p>
<a href="https://readerstacks.com" target="_top">readerstacks.com</a>
</p>
</div>
</div>
</body>
</html>
Also Read : How to Share URL on social media using package in Laravel 9/8/7/6/5 ?