コード例 #1
0
	<input type="submit" value="Send me a POSTed registration!">
	</form>
	</html>
<?php 
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
    //########################################################
    //# Example sending via PHP to the Proximus REST API
    //########################################################
    $msisdn = $_REQUEST['msisdn'];
    $email = $_REQUEST['email'];
    $zipcode = $_REQUEST['zipcode'];
    $gender = $_REQUEST['gender'];
    $carrier = $_REQUEST['carrier'];
    $category = urlencode($_REQUEST['category']);
    $rawurl = $baseurl . $username . "/" . $api_password . "/" . $msisdn . "/" . $email . "/" . $zipcode . "/" . $carrier . "/" . $gender . "/" . $category;
    $tokenGenerator = new ProximusToken($company_salt);
    $token = $tokenGenerator->generateAuthenticationToken($rawurl);
    $post = array('username' => $username, 'token' => $token, 'msisdn' => $msisdn, 'email' => $email, 'zipcode' => $zipcode, 'carrier' => $carrier, 'gender' => $gender, 'category' => $category, 'responseType' => 'JSON');
    $post_body = http_build_query($post);
    // send the request using PHP curl
    $ch = curl_init();
    $fields = array('__VIEWSTATE' => urlencode($state), '__EVENTVALIDATION' => urlencode($valid), 'btnSubmit' => urlencode('Submit'));
    //set the url, number of POST vars, POST data
    //curl_setopt($ch,CURLOPT_URL,$baseurl);
    curl_setopt($ch, CURLOPT_URL, "http://192.168.1.211:8080/ProximusTomorrow-war/api/webregistration");
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
    //execute POST
    $result = curl_exec($ch);
    print $result;
}
コード例 #2
0
<?php

/*
 * @Copyright 2012, Proximus Mobility, LLC., all rights reserved
 * @author dshaw
 */
class ProximusToken
{
    public function __construct($salt)
    {
        $this->salt = $salt;
    }
    public function generateAuthenticationToken($url)
    {
        $toEncode = $this->salt . $url;
        return strtoupper(md5($toEncode));
    }
}
$tokenGenerator = new ProximusToken("MYCOMPANYISAWESOME");
$URL_BASE = "http://devices.proximusmobility.com/api/";
$username = urlencode("*****@*****.**");
$password = "******";
$encodingUrl = $URL_BASE . $username . "/" . $password . "/params1/params2/params..n";
$token = $tokenGenerator->generateAuthenticationToken($encodingUrl);
$requestUrl = $URL_BASE . $username . "/" . $token . "/params1/params2/params..n";
print "Raw URL was " . $encodingUrl . "<br/>\n";
print "Token would be " . $token . "<br/>\n";
print "Request URL would be " . $requestUrl . "<br/>\n";