I'm trying to implement a simple login with Sharepoint on a PHP existing application. I have read many information (some related to Client side login -but only works for windows AFAIK-) and forums like this one [1] and with this approach I been able to login with the credentials of a user in a trial of Office365.

You can test it here with:

Login: cristianpark
Password: crisPaRK01
Host: https://almeraim.sharepoint.com

It says 'login satisfactorio' (successful login) but if I try with some user from a registered sharepoint, I don't know how is the plan they have but they use emails like: [email protected] instead of [email protected], with credentials like that, the script doesn't work, it shows some text on red. I'll try another things I have read but I want to know if you know if there is a better way of accomplish the login in a Linux box with PHP

Thanks in advance

[1] http://macfoo.wordpress.com/2012/06/23/how-to-log-into-office365-or-sharepoint-online-using-php/

2 Answers 2


phpSPO - SharePoint client for PHP The library provides a SharePoint Online (SPO) client for PHP applications. It allows you to performs CRUD operations on SharePoint data using an SharePoint 2013 REST/OData based API.


How to perform authentication in SharePoint Online (SPO):

try {
    $client = new SPOClient($url);
    echo 'You have authenticated successfully\n';
catch (Exception $e) {
    echo 'Authentication failed: ',  $e->getMessage(), "\n";

The following examples demonstrates how to perform CRUD operations on SharePoint list data:


require_once 'SPOClient.php';

$username = '[email protected]';
$password = 'password';
$url = "https://tenant.sharepoint.com/";

$client = new SPOClient($url);

//Get Tasks list
$listTitle = 'Tasks';
$list = $client->getList($listTitle);

//Create a Task item
$itemProperties = array('Title' => 'Order Approval', 'Body' => 'Order approval task');
$taskItem = $list->addItem($itemProperties);
print "Task '{$taskItem->Title}' has been created succesfully.\r\n";

$itemId = $taskItem->Id;
//Update a Task item
$itemProperties = array('PercentComplete' => 1);

//Delete a Task item



SharePoint Online client for PHP


The script will only work with registered users, given access to your trial tennent (i believe you get 10 users maximum). On the other hand, if you haven't configured your own domain in Office 365 than you can only use [email protected].

If you plan to Federate with your own domain, that is totally another story and it requires so much more configuration or the use of ACS from Azure.

  • Enter when I shouldn't ¬¬ I must say I'm not familiar with MS Services and I don't know if the last you say is the case. What I'm looking for is authenticate users from a sharepoint online enterprise.sharepoint.com where users have emails like [email protected] (instead of @entreprise.onmicrosoft.com like the ones of the office365 trial), with the users from trial the script works, but with the others from a existing sharepoint with custom domain, it doesn't, I have to configure something on that sharepoint admin?? May 30, 2013 at 17:24
  • Yes, prior to being able to login with your organisation account you need to configure your domain inside Office365 (onlinehelp.microsoft.com/en-us/office365-enterprises/…). Secondly, you need to federate with your own domain if you plan to have your users to login with the same credentials as in your own AD. Alternatively, you should be able to Invite external people with other email addresses, and they should configure their own connection. May 30, 2013 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.