Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 http://64.131.76.111/msauth.php 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: cristianpark@entreprise.com.co instead of cristianpark@enterprise.onmicrosoft.com, 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/

share|improve this question

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.

Examples

How to perform authentication in SharePoint Online (SPO):

try {
    $client = new SPOClient($url);
    $client->signIn($username,$password);
    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:

<?php

require_once 'SPOClient.php';

$username = 'username@tenant.onmicrosoft.com';
$password = 'password';
$url = "https://tenant.sharepoint.com/";

$client = new SPOClient($url);
$client->signIn($username,$password);

//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);
$list->updateItem($itemId,$itemProperties);

//Delete a Task item
$list->deleteItem($itemId);

?>

References

SharePoint Online client for PHP

share|improve this answer

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 user@domain.onmicrosoft.com.

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.

share|improve this answer
    
Hi C. Marius, thanks for your answer –  Cristianpark May 30 '13 at 17:16
    
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 user@enterprise.com.co (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?? –  Cristianpark May 30 '13 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. –  C. Marius - MVP May 30 '13 at 22:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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