<?php
//Sample Usage
//FYI, Ensure the SOAP and OpenSSL extensions are enabled on your PHP server.

require_once('MSTag_v2.php');

$MSTagAuthToken = "My Auth Token";

//Create an MSTag interface instance
$msTag = new MSTag();

//Create User Credentials
$userCredential = new UserCredential($MSTagAuthToken);

//Create a new category
$category = new Category();
$category->setName('TestCategory');
$result = $msTag->CreateCategory($userCredential, $category);

//Update a category
$categoryUpdate = new Category();
$categoryUpdate->setName('TestCategory2');
$categoryUpdate->setUTCStartDate(new DateTime('2010-09-25'));
$result = $msTag->UpdateCategory($userCredential, 'TestCategory', $categoryUpdate);

//Pause a category
$result = $msTag->PauseCategory($userCredential, 'TestCategory2');

//Activate a category
$result = $msTag->ActivateCategory($userCredential, 'TestCategory2');

//Create a new URL tag
$tag = new URITag();
$tag->setTitle('TestTag1');
$tag->setMedFiUrl('http://somesite.com');
$result = $msTag->CreateTag($userCredential, 'TestCategory2', $tag);

//Create a new FreeText tag
$freeTextTag = new FreeTextTag();
$freeTextTag->setTitle('TestFreeText1');
$freeTextTag->setFreeText('Here comes a free text message');
$freeTextTag->setUTCStartDate(); //Defaults to now
$freeTextTag->setUTCEndDate(new DateTime('2011-08-18'));
$result = $msTag->CreateTag($userCredential, 'TestCategory2', $freeTextTag);

//Update a tag
$updateTag = new URITag();
$updateTag->setTitle('TestTag1');
$updateTag->setMedFiUrl('http://somesite2.com');
$result = $msTag->UpdateTag($userCredential, 'TestCategory2','TestTag1', $updateTag);

//Pause a tag
$result = $msTag->PauseTag($userCredential, 'TestCategory2','TestTag1');

//Activate a tag
$result = $msTag->ActivateTag($userCredential, 'TestCategory2','TestTag1');

//Delete a tag
$result = $msTag->DeleteTag($userCredential, 'TestCategory2','TestFreeText1');

//Get a Tag ID
$id = $msTag->GetTagID($userCredential, 'TestCategory2','TestTag1');

//Display Microsoft Tag image in browser
$result = $msTag->GetBarcode($userCredential,'TestCategory2','TestTag1','jpeg',2);

// or alternately, display as a QR code in browser
//$result = $msTag->GetQRCode($userCredential,'TestCategory2','TestTag1','jpeg',2);

if($result){
ob_start();
$length = strlen($result);
header('Last-Modified: '.date('r'));
header('Accept-Ranges: bytes');
header('Content-Length: '.$length);
header('Content-Type: image/jpeg');
print($result);
ob_end_flush();
exit;
} else {
echo $msTag->getLastException();
}


Last edited May 22, 2012 at 5:16 PM by tbbucs4755, version 9

Comments

xietian0517 Aug 13, 2012 at 4:07 AM 
I want to know how to add a payload to the tag.Anyone help?

dsoprea Feb 6, 2012 at 4:16 PM 
Note, above, that the following line uses incorrect credentials variable $oCredential. All previous lines have used $userCredential.

$result = $msTag->GetBarcode($oCredential,'TestCategory2','TestTag1','jpeg',2);

Eloelle Mar 1, 2011 at 3:01 PM 
Is there any way to record device id's or would that be a different project?