Using Task API getSessionState with PHP in IIS

Hello there!

Today let’s talk about how to create a session using PHP with IIS.

First, enable Basic Authentication on MicroStrategy Virtual Site in IIS.

You just have to use this code:

<?php
$username = 'username';
$password = 'password';
$context = stream_context_create(array(
 'http' => array(
 'header' => "Authorization: Basic " . base64_encode("$username:$password")
 )
));
$url = file_get_contents("http://localhost/MicroStrategy/asp/TaskAdmin.aspx? 
taskId=getSessionState&taskEnv=xml&taskContentType=xml&server=localhost&project=MicroStrategy 
+Tutorial&uid=administrator&pwd=", false, $context);
$data=simplexml_load_string($url);


foreach($data->children() as $child) {
foreach($child->children() as $child1) {
$sessionmstr = $child1;
break;
}
}
header(“Location: http://server/Microstrategy/asp/Main.aspx?evt=2048001&src=Main.aspx.2048001&visMode=0&currentViewMedia=2&documentID=IDOFTHEDOCUMENT1&server=server&Project=NAMEOFTHEPROJECT&port=0&share=1&usrSmgr=$sessionmstr“);
?>

Remember to change the username and password to use your username and password for login in TASK API page. And in file_get_contents and header(“Location…, change the url to use your own urls.

Hope it helps!
God bless you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s