src/Thybag/Auth/SharePointOnlineAuth.php
protected function configureAuthCookies($location) {

		// Get endpoint "https://somthing.sharepoint.com"
		$location = parse_url($location);
		$endpoint = 'https://'.$location['host'];

		// get username & password
		$login = $this->{'_login'};
		$password = $this->{'_password'};

		// Create XML security token request
		$xml = $this->generateSecurityToken($login, $password, $endpoint);

		// Send request and grab returned xml
		$result = $this->authCurl("https://login.microsoftonline.com/extSTS.srf", $xml);

		
		// Extract security token from XML
		$xml = new \DOMDocument();
		$xml->loadXML($result);
		$xpath = new \DOMXPath($xml);

		// Register SOAPFault namespace for error checking
		$xpath->registerNamespace('psf', "http://schemas.microsoft.com/Passport/SoapServices/SOAPFault");

		// Try to detect authentication errors
		$errors = $xpath->query("//psf:internalerror");
		if($errors->length > 0){
			$info = $errors->item(0)->childNodes;
			throw new \Exception($info->item(1)->nodeValue, $info->item(0)->nodeValue);
		}

		$nodelist = $xpath->query("//wsse:BinarySecurityToken");
		foreach ($nodelist as $n){
			$token = $n->nodeValue;
			break;
		}

		if(!isset($token)){
			throw new \Exception("Unable to extract token from authentiction request");
		}

		// Send token to SharePoint online in order to gain authentication cookies
		$result = $this->authCurl($endpoint."/_forms/default.aspx?wa=wsignin1.0", $token, true);

		// Extract Authentication cookies from response & set them in to AuthCookies var
		$this->authCookies = $this->extractAuthCookies($result);
	}
protected function configureAuthCookies($location) {

		// Get endpoint "https://somthing.sharepoint.com"
		$location = parse_url($location);
		$endpoint = 'https://'.$location['host'];

		// get username & password
		$login = $this->{'_login'};
		$password = $this->{'_password'};

		// Create XML security token request
		$xml = $this->generateSecurityToken($login, $password, $endpoint);

		// Send request and grab returned xml
		$result = $this->authCurl("https://login.microsoftonline.com/extSTS.srf", $xml);

		
		// Extract security token from XML
		$xml = new \DOMDocument();
		$xml->loadXML($result);
		$xpath = new \DOMXPath($xml);

		// Register SOAPFault namespace for error checking
		$xpath->registerNamespace('psf', "http://schemas.microsoft.com/Passport/SoapServices/SOAPFault");

		// Try to detect authentication errors
		$errors = $xpath->query("//psf:internalerror");
		if($errors->length > 0){
			$info = $errors->item(0)->childNodes;
			throw new \Exception($info->item(1)->nodeValue, $info->item(0)->nodeValue);
		}

		$nodelist = $xpath->query("//wsse:BinarySecurityToken");
		foreach ($nodelist as $n){
			$token = $n->nodeValue;
			break;
		}

		if(!isset($token)){
			throw new \Exception("Unable to extract token from authentiction request");
		}

		// Send token to SharePoint online in order to gain authentication cookies
		$result = $this->authCurl($endpoint."/_forms/default.aspx?wa=wsignin1.0", $token, true);

		// Extract Authentication cookies from response & set them in to AuthCookies var
		$this->authCookies = $this->extractAuthCookies($result);
	}
protected function configureAuthCookies ( $ location ) { // Get endpoint "https://somthing.sharepoint.com" $ location = parse_url ( $ location ) ; $ endpoint = 'https://' . $ location [ 'host' ] ; // get username & password $ login = $ this -> { '_login' } ; $ password = $ this -> { '_password' } ; // Create XML security token request $ xml = $ this -> generateSecurityToken ( $ login , $ password , $ endpoint ) ; // Send request and grab returned xml $ result = $ this -> authCurl ( "https://login.microsoftonline.com/extSTS.srf" , $ xml ) ; // Extract security token from XML $ xml = new \ DOMDocument ( ) ; $ xml -> loadXML ( $ result ) ; $ xpath = new \ DOMXPath ( $ xml ) ; // Register SOAPFault namespace for error checking $ xpath -> registerNamespace ( 'psf' , "http://schemas.microsoft.com/Passport/SoapServices/SOAPFault" ) ; // Try to detect authentication errors $ errors = $ xpath -> query ( "//psf:internalerror" ) ; if ( $ errors -> length > 0 ) { $ info = $ errors -> item ( 0 ) -> childNodes ; throw new \ Exception ( $ info -> item ( 1 ) -> nodeValue , $ info -> item ( 0 ) -> nodeValue ) ; } $ nodelist = $ xpath -> query ( "//wsse:BinarySecurityToken" ) ; foreach ( $ nodelist as $ n ) { $ token = $ n -> nodeValue ; break ; } if ( ! isset ( $ token ) ) { throw new \ Exception ( "Unable to extract token from authentiction request" ) ; } // Send token to SharePoint online in order to gain authentication cookies $ result = $ this -> authCurl ( $ endpoint . "/_forms/default.aspx?wa=wsignin1.0" , $ token , true ) ; // Extract Authentication cookies from response & set them in to AuthCookies var $ this -> authCookies = $ this -> extractAuthCookies ( $ result ) ; }
ConfigureAuthCookies
Authenticate with sharepoint online in order to get valid authentication cookies

@param $location - Url of sharepoint list

More info on method:
@see http://allthatjs.com/2012/03/28/remote-authentication-in-sharepoint-online/
@see http://macfoo.wordpress.com/2012/06/23/how-to-log-into-office365-or-sharepoint-online-using-php/
ConfigureAuthCookies Authenticate with sharepoint online in order to get valid authentication cookies