The example demonstrates how to generate SharePoint List data from PHP application
<?php | |
require_once __DIR__ . '/../../Faker/src/autoload.php'; //Faker library (https://github.com/fzaninotto/Faker) | |
require_once 'SPOClient.php'; | |
$username = 'username@tenant.onmicrosoft.com'; | |
$password = 'password'; | |
$url = "https://tenant.sharepoint.com/"; | |
generateContacts($url,$username,$password); | |
function generateContacts($url,$username,$password){ | |
$client = new SPOClient($url); | |
$client->signIn($username,$password); | |
$list = $client->getList('Contacts'); | |
$contactsCount = 120; | |
for($i = 0; $i < $contactsCount; $i++){ | |
$contactEntry = createContactEntry(); | |
$item = $list->addItem($contactEntry); | |
print "Contact '{$item->Title}' has been created succesfully.\r\n"; | |
} | |
} | |
function createContactEntry() | |
{ | |
$contactCard = Faker\Factory::create(); | |
return array('Title' => $contactCard->username, | |
'FullName' => $contactCard->name, | |
'Email' => $contactCard->email, | |
'Company' => $contactCard->company, | |
'WorkPhone' => $contactCard->phoneNumber, | |
'WorkAddress' => $contactCard->streetAddress, | |
'WorkCity' => $contactCard->city, | |
'WorkZip' => $contactCard->postcode, | |
'WorkCountry' => $contactCard->country, | |
'WebPage' => array ('Url' => $contactCard->url) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment