PHP Example
Continuing from the example in Your First Message Template, you can send your transactional message in php with the following.
1
<?php
2
$url = "https://txnhog.co/txn/api/your_message_key";
3
​
4
$curl = curl_init($url);
5
curl_setopt($curl, CURLOPT_URL, $url);
6
curl_setopt($curl, CURLOPT_POST, true);
7
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
8
​
9
$headers = array(
10
"Content-Type: application/x-www-form-urlencoded",
11
);
12
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
13
​
14
$data = "apiKey=sdkrjwhaldkgh3pwdfohawp4lyu&name=Shawn%20Spencer&phone=2085559988";
15
​
16
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
17
​
18
$resp = curl_exec($curl);
19
curl_close($curl);
20
var_dump($resp);
21
?>
Copied!
Last modified 6mo ago
Copy link