Sharepoint - Office 365 login on PHP

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

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

profilepic.png
manpreet 2 years ago

 

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);

?>

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community