Пример #1
0
 private static function _notify($address, $tag, $info, $link)
 {
     $sms = new SMSified(SMS_USER, SMS_PWD);
     if ($address) {
         $subject = $tag . ' notification';
         $message = $info . ", " . $link;
         $request = sprintf("address=%s&message=%s", $address, $message);
         print "Request: {$request}\n";
         $url = PUSHURL;
         $response = $sms->sendMessage(SMS_SENDER, $address, $message);
         $responseJson = json_decode($response);
         print 'Response:' . "\n";
         print_r($responseJson);
         print "\n";
         $success = $responseJson;
     } elseif (0) {
         $contents = array('badge' => '1', 'alert' => 'New item for ' . $tag);
         $push = array('aps' => $contents);
         $json = json_encode($push);
         $session = curl_init(PUSHURL);
         curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET);
         curl_setopt($session, CURLOPT_POST, true);
         curl_setopt($session, CURLOPT_POSTFIELDS, $json);
         curl_setopt($session, CURLOPT_HEADER, false);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
         $content = curl_exec($session);
         echo $content;
         // just for testing what was sent
         // Check if any error occured
         $response = curl_getinfo($session);
         curl_close($session);
         $success = $response['http_code'] == 200;
     }
     return $success;
 }
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
$senderAddress = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Subscribe to status updates for a number and decode the JSON response from SMSified.
    $response = $sms->viewSubscriptions($senderAddress, MessageDirection::$outbound);
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Check the status of an SMS message and decode the JSON response from SMSified.
    $response = $sms->getMessages("047bb537cca6f278c2d59729fd7w1456");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
$senderAddress = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Check the status of an SMS message and decode the JSON response from SMSified.
    $response = $sms->checkStatus($senderAddress, "6c7ec0327c18f28b1a6ee2dc3383ae6a");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
Пример #5
0
<?php

require 'includes/smsified.class.php';
$message = $_REQUEST["message"];
$address = $_REQUEST["address"];
$username = "******";
$password = "******";
$senderAddress = "19493909951";
try {
    $sms = new SMSified($username, $password);
    $response = $sms->sendMessage($senderAddress, $address, $message);
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
// Checks response
try {
    $response = $sms->getMessages("047bb537cca6f278c2d59729fd7w1456");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
echo "{$message} : {$address} <br/>";
?>


Пример #6
0
    // Get the JSON payload sumbitted from SMSified.
    $json = file_get_contents("php://input");
    // Create a new instance of the custom object.
    $sms = new InboundMessage($json);
    // Get the message sent with the inbound message.
    $message = $sms->getMessage();
    // Get the number message was sent from.
    $number = $sms->getSenderAddress();
    // Look up latest review for establishment.
    $conn = new DBConnect(DB_HOST, DB_USER, DB_PASSWORD);
    $conn->selectDB(DB_NAME);
    $query = str_replace("{NAME}", $conn->escapeInput($message), SQL_QUERY_TEMPLATE);
    $result = $conn->runQuery($query);
    // Construct response to send back to user.
    if ($conn->getNumRowsAffected() == 0) {
        $response = "No establishments found";
    } else {
        $review = mysql_fetch_assoc($result);
        $response = 'Name: ' . $review["Est_Name"] . ' ';
        $response .= 'Insp. Date: ' . $review["I_Date"] . ' ';
        $response .= 'Score: ' . $review["Score"] . ' ';
        $response .= 'Grade: ' . $review["Grade"];
    }
    // Create a new instance of the SMSified object.
    $sms = new SMSified(SMS_USER, SMS_PASSWORD);
    $sms->sendMessage(SMS_SENDER_NUMBER, $number, $response);
} catch (Exception $ex) {
    openlog("DERBYCITYFOOD", LOG_ODELAY, LOG_USER);
    syslog(LOG_ERR, "There was a problem.");
    closelog();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Check the status of an SMS message and decode the JSON response from SMSified.
    @($response = $sms->getMessages());
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Subscribe to status updates for a number and decode the JSON response from SMSified.
    $response = $sms->deleteSubscriptions("8da123e54f91ee0dfb8ead8d4d60a318", MessageDirection::$outbound);
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
$senderAddress = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Subscribe to status updates for a number and decode the JSON response from SMSified.
    $response = $sms->createSubscription($senderAddress, MessageDirection::$outbound, "http://path-to-somewhere/file.php");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
Пример #10
0
 public function tell_friend($address, $data)
 {
     $sms = new SMSified(SMS_USER, SMS_PWD);
     if ($address) {
         $code = User::generate_user_code();
         $link = $_SERVER['HTTP_HOST'] . "/fyi/{$code}";
         $message = sprintf("%s\n%s\n%s\n- %s", $link, $data['title'], $data['message'], $data['name']);
         $request = sprintf("address=%s&message=%s", $address, $message);
         $url = PUSHURL;
         $response = $sms->sendMessage(SMS_SENDER, $address, $message);
         $responseJson = json_decode($response);
         //print 'Response:<pre>';
         //print_r($responseJson);
         //print "</pre>";
         $success = $responseJson;
         $tf = new Tell_Friend();
         $tf->code($code);
         $tf->user_id($data['user_id']);
         $tf->phone($address);
         $tf->city_id($data['city_id']);
         $tf->issue_type($data['issue_type']);
         $tf->issue_id($data['issue_id']);
         $tf->message($data['message']);
         $tf->created_date(TODAY_DATETIME);
         $tf->insert();
     } elseif (0) {
         $contents = array('badge' => '1', 'alert' => 'New item for ' . $tag);
         $push = array('aps' => $contents);
         $json = json_encode($push);
         $session = curl_init(PUSHURL);
         curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET);
         curl_setopt($session, CURLOPT_POST, true);
         curl_setopt($session, CURLOPT_POSTFIELDS, $json);
         curl_setopt($session, CURLOPT_HEADER, false);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
         $content = curl_exec($session);
         echo $content;
         // just for testing what was sent
         // Check if any error occured
         $response = curl_getinfo($session);
         curl_close($session);
         $success = $response['http_code'] == 200;
     }
     return $success;
 }
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
$senderAddress = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Send an SMS message and decode the JSON response from SMSified.
    $response = $sms->sendMessage($senderAddress, "14078971234", "PHP Rocks!");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
$senderAddress = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Send an SMS message and decode the JSON response from SMSified.
    $response = $sms->sendMessage($senderAddress, "14072341256", "I really love coding in PHP with callback.", "http://path-to-somewhere/file.php");
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}
<?php

// Include the SMSifed class.
require '../smsified.class.php';
// SMSified Account settings.
$username = "";
$password = "";
try {
    // Create a new instance of the SMSified object.
    $sms = new SMSified($username, $password);
    // Check the status of an SMS message and decode the JSON response from SMSified.
    $response = $sms->getMessages(null, array("status" => "fail", "direction" => "out"));
    $responseJson = json_decode($response);
    var_dump($response);
} catch (SMSifiedException $ex) {
    echo $ex->getMessage();
}