PHP Sample: OptInCustomer

Note: In the OptInCustomer method, first_name and last_name are required parameters, but you may leave the value blank.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?PHP
$userid= 'userid'; $passwd= 'password'; $keyword='keyword'
$postFields = "method=optincustomer&firstname=Jim&lastname=Bigbird&phone_number=9995552222";
$authString = $userid . ':'. $passwd . ':'. $keyword ; $centralUrl="https://restapi.crmtext.com/smapi/rest" ;
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $centralUrl );
curl_setopt ( $ch, CURLOPT_FAILONERROR, 1 );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 6 );
curl_setopt ( $ch, CURLOPT_POST, true );
writer.Close();
curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt ($ch,CURLOPT_USERPWD,$authString);
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postFields );
try {
$result = curl_exec ( $ch );
curl_close($ch);
}catch (Exception $e) {
echo <Error Message> . $e->getMessage();
}
?>

PHP Sample: SendSMSmsg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?PHP
$userid= 'userid'; $passwd= 'password'; $keyword='keyword'
$postFields = ""method=sendsmsmsg&phone_number=9995551212&message=Thanh Long has the best roast crab ever.";
$authString = $userid . ':'. $passwd . ':'. $keyword ; $centralUrl="https://restapi.crmtext.com/smapi/rest" ;
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $centralUrl );
curl_setopt ( $ch, CURLOPT_FAILONERROR, 1 );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 6 );
curl_setopt ( $ch, CURLOPT_POST, true );
writer.Close();
curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt ($ch,CURLOPT_USERPWD,$authString);
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postFields );
try {
$result = curl_exec ( $ch );
curl_close($ch);
}catch (Exception $e) {
echo <Error Message> . $e->getMessage();
}
?>

PHP Sample: SetCallback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?PHP
$userid= 'userid'; $passwd= 'password'; $keyword='keyword'
$postFields = ""method=setcallback&callback=https://yourcallbackurlwebhooklistener.com";
$authString = $userid . ':'. $passwd . ':'. $keyword ; $centralUrl="https://restapi.crmtext.com/smapi/rest" ;
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $centralUrl );
curl_setopt ( $ch, CURLOPT_FAILONERROR, 1 );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 6 );
curl_setopt ( $ch, CURLOPT_POST, true );
writer.Close();
curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt ($ch,CURLOPT_USERPWD,$authString);
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postFields );
try {
$result = curl_exec ( $ch );
curl_close($ch);
}catch (Exception $e) {
echo <Error Message> . $e->getMessage();
}
?>

PHP Sample: Web Hook Mobile Originated Capture Set-Up

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?PHP
echo "called";
$string = '';
if (isset[$_REQUEST["custID"])) {
   $string .= 'custID = '. $_REQUEST['custID'];
}
isset($_REQUEST["keyword"])) {
   $string .= 'keyword = '. $_REQUEST['keyword'];
}
isset($_REQUEST["message"])) {
   $string .= 'message = '. $_REQUEST['message'];
}
isset($_REQUEST["mobileNum"])) {
   $string .= 'mobileNum = '. $_REQUEST['mobileNum'];
}
isset($_REQUEST["optInStatus"])) {
   $string .= 'optInStatus = '. $_REQUEST['optInStatus'];
}
isset($_REQUEST["timeStamp"])) {
   $string .= 'timeStamp = '. $_REQUEST['timeStamp'];
}
isset($_REQUEST["subacct"])) {
   $string .= 'subacct = '. $_REQUEST['subacct'];
}
isset($_REQUEST["subacct_name"])) {
   $string .= 'subacct_name = '. $_REQUEST['subacct_name'];
}
isset($_REQUEST["custName"])) {
   $string .= 'custName = '. $_REQUEST['custName'];
}
isset($_REQUEST["msgID"])) {
    $string .= 'msgID = '. $_REQUEST['msgID'];
}
isset($_REQUEST["mms"])) {
   $string .= 'mms = '. $_REQUEST['mms'];
}
$fp = fopen('test/demoserverlog.txt','a+');
fwrite($fp,$string);
fwrite($fp,print_r($_REQUEST,true));
fwrite($fp,"called");
fwrite($fp);
?>