Our new API now supports api keys, meaning the login details for a Textlocal account can be separate from those used to access the API!
We’ve been asked about it quite a few times since our new API went live last year, and as always, when customers ask, we deliver!
An example of this would be:
- You’ve created a Textlocal account, and now want to integrate the API with your software or website.
- Your software developers will need to do this, and so that they don’t have full access to your account, you can provide them with an apiKey just for them.
Another example will be where you have multiple API calls to us from different servers/services, and again you want each to have it’s own access so that it can be tracked. And you can also limit each apiKey by IP address – another level of security.
It also means that if you reset your Textlocal account email address and/or password, it won’t change the apiKey!
Here’s a PHP code example using our Send API:
- // Textlocal account details
- $apikey = ‘028337580-30wq7g5neuwnrgeyugh’;
- // Message details
- $numbers = array(447123456789, 447987654321);
- $sender = urlencode(‘YourName’);
- $message = urlencode(‘This is your message’);
- $numbers = implode(‘,’, $numbers);
- // Prepare data for POST request
- $data = array(‘apikey’ => $apikey, numbers’ => $numbers, “sender” => $sender, “message” => $message);
- // Send the POST request with cURL
- $ch = curl_init(‘http://api.txtlocal.com/send/’);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
- // Process your response here
- echo $response;