Category: PHP Development

PHP Development

How to send SMS using PHP

In this tutorial, we have explained how to send SMS using PHP. There are many SMS API service providers like Twilio, Nexmo, MSG91, Text local that you can use to send SMS using the PHP programming language. In this tutorial we learned how to send SMS using twilio API service provider. Twilio’s APIs (Application Programming Interfaces) power its platform for communications. Behind these APIs is a software layer connecting and optimizing communications networks around the world to allow your users to call and message anyone, globally. Twilio has a whole host of APIs, from SMS to Voice to Wireless! Step 1: Register for Twilio account Sign Up for free twilio account from here :  Step 2: Verify Phone Number Next, we need to create a phone number for your account from which you can send the SMS Click -> “Phone Numbers” in the sidebarClick -> “Get a number now” link to generate your own phone numberNow “Click -> Get your first Twilio phone number”.Once you click “Get your first Twilio phone number”, a new pop-up window will show your Twilio Phone Number. Now, click “Choose this Number”. Step 3: Create API Credentials Next, you need to get your account SID and your authorization token.On the Console Dashboard page you can get your credentials. Step 4: Install PHP SDK The method of installing the SDK is via composer composer require twilio/sdk The another method of installing the SDK without composer is possible to download and use the PHP SDK manually and unzip SDK folder into your project directory. You can download from here. Step 7: Create Integration <?php require __DIR__ . ‘/vendor/autoload.php’; //with composer // based on where you downloaded and unzipped the SDK require __DIR__ . ‘/twilio-php-main/src/Twilio/autoload.php’; //without composer use Twilio\Rest\Client; // Your Account SID and Auth Token from twilio.com/console $account_sid = ‘ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’; $auth_token = ‘your_auth_token’; // In production, these should be environment variables. E.g.: // $auth_token = $_ENV[“TWILIO_AUTH_TOKEN”] // A Twilio number you own with SMS capabilities $twilio_number = “+15558675309”; $client = new Client($account_sid, $auth_token); $client->messages->create( // Where to send a text message (your cell phone?) ‘+15017250604’, array( ‘from’ => $twilio_number, ‘body’ => ‘My first trial SMS!’ ) ); Step 5: Receiving a SMS Here you go! Note: Trial accounts cannot send messages to unverified numbers; verify +9198XXX42887 at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers. Conclusion: I hope this tutorial helpful for you, if you have any issue with integration, please comment below. Thank You!
Timezone
PHP Development

Dynamic Timezone : Same Time in Different Countries

In this tutorial we have explained how to create dynamic time zone which shows same time for different countries. You can use this feature for your online schedules to provide time to all users according to their country time. <script type=”text/javascript”> function dynamicTimeChange(timezone){ let date = new Date(Date.UTC(0, 0, 0, 13, 0, 0)); SlotTime = date.toLocaleString(“en-US”, {timeZone: timezone, hour: ‘2-digit’, minute:’2-digit’}); document.getElementById(“dynamictzDiv”).innerHTML = SlotTime; } </script> <label style=”text-align: center;font-size: initial;”>Select Your Timezone</label> <?php function select_Timezone($selected = ”) { // Create a list of timezone $OptionsArray = timezone_identifiers_list(); $select= ‘<select name=”SelectContacts” onchange=”dynamicTimeChange(this.value);” id=”selectTime” style=”width: 120px;font-family: FontAwesome;”> <option disabled selected> Please Select Timezone </option> <option value=”Canada/Pacific”>Canada/Pacific Standard Time</option> <option value=”Canada/Atlantic”>Canada/Atlantic Standard Time</option> <option value=”Australia/West”>Australian Central Western Standard Time&amp;lt;/option&amp;gt; <option value=”Australia/Queensland”>Australia/Australian Eastern Standard Time</option>’; $select.='</select>’; return $select; } echo select_Timezone() . ‘<br>’; ?> <div class=”timeDivPremiumSch” style=”margin-top: 12px;”> <label id=”dynamictzDiv”>05:00 AM</label> </div> ?> Output: You can add Timezones in select list according to your needs. When you change the timezone from select dropdown list, it will change the time of label which is currently “05:00 AM” and display new time of your selected time. Here, I used “05:00 AM” as a static time so in this we can find your timezone’s “05:00 AM” of any other timezone. Date.UTC(0, 0, 0, 13, 0, 0) here, ’13’ is describing hour, you can add as your static time it will must be between 0-24. Conclusion: I hope this tutorial helpful for you, if you have any issue with this, please comment below. Thank You!
PHP Development

PHP Development

Top 9 Blogs for PHP Developers Dr. Michael J. Garbade October 20, 2016 5 Comments

phpmaha

PHP, a server-side scripting programming language, has managed a glorious journey since its inception in 1994. Little did the programmers knew, when Rasmus Lerdorf developed PHP, his creation would one day find a place as one of the top five programming languages.

PHP Development

PHP Development

Being the torchbearer of web development for so long, it does not surprise me one single bit when I notice the exponential growth in PHP enthusiasts all over the world. With enthusiasm comes the curiosity of learning more, and with the curiosity comes the attempt to find the best way to learn the language.

×