Last active
August 29, 2015 14:02
-
-
Save vgrem/22d587064ab771131811 to your computer and use it in GitHub Desktop.
The example demonstrates how to generate SharePoint List data from PHP application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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