How to?

Calling a mobile phone from your website

Enable your site visitors to call mobile numbers while they are on the site.

The following guide explains how to create a web form that enables users to make calls to a specified number via a REST API request.

Download source

How it works

This PHP sample application demonstrates the creation of a web contact form that calls a specified mobile number from your Apifonica account. The call is made using the data the user specifies in the form. Call status is then checked using Apifonica API.

Let’s get started!

Prerequisites

  1. An Apifonica account SID and password to make phone calls from a web site. You can find these in your personal account.
  2. An application SID for an application you have registered at the Apifonica Account web site’s Manage Applications page.
  3. An Apifonica phone number to call from. You can rent a number from your Apifonica account.
  4. An Apache/nginx HTTP server supporting PHP version 5 or higher and cURL.

Step 1. Get the Code

Click here to download the source (call.php), which includes everything you need in this example.

The file contains an HTTP form to be displayed to site visitors, as well as the backend function to make the call to the predefined mobile number and check its status.

The following diagram demonstrates how the sample works.

Step 2. Upload the Source Code File to Your Server

Copy the source code file you have downloaded to a directory on your web server capable of serving PHP code

Step 3. Open the Web Form on Your Web Site and Fill Out the Required Data

Fill in the fields in the web form. You will need to fill out the following fields:

  • Your account SID.
  • Your account password (authToken).
  • Your application SID.
  • A number you have rented for this account. It will be used as the caller’s number.
  • A recipient’s mobile phone number.

Step 4. Make the Call

Click the Make Your Call button to execute the call from your browser. The mobile phone you have specified in the input form should receive the call shortly.

The Apifonica account with the credentials you have provided will be charged for the outgoing calls from your web server to the mobile number(s) you have specified.

Step 5. Check the Message Delivery

Click the Check Your Call Status button to verify that your call has been successfully created.