Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Requires the NuSOAP library
- require_once('lib/nusoap.php');
- $username = 'yourUsername';
- $password = 'yourPassword';
- $rowLimit = '150';
- /* A string that contains either the display name or the GUID for the list.
- * It is recommended that you use the GUID, which must be surrounded by curly
- * braces ({}).
- */
- $listName = "TempList";
- /*
- * Example field (aka columns) names and values, that will be used in the
- * CAML query. The values are the attributes of a single list item here.
- * If the field name contains a space in SharePoint, replace it
- * here with _x0020_ (including underscores).
- */
- $field1Name = "Title";
- $field2Name = "Address";
- $field3Name = "Premium_x0020_customer";
- $field1Value = "John Smith";
- $field2Value = "USA";
- $field3Value = "1";
- /* Local path to the Lists.asmx WSDL file (localhost). You must first download
- * it manually from your SharePoint site (which should be available at
- * yoursharepointsite.com/subsite/_vti_bin/Lists.asmx?WSDL)
- */
- $wsdl = "http://localhost/phpsp/Lists.wsdl";
- //Basic authentication is normally used when using a local copy a the WSDL. Using UTF-8 to allow special characters.
- $client = new nusoap_client($wsdl, true);
- $client->setCredentials($username,$password);
- $client->soap_defencoding='UTF-8';
- //CAML query (request), add extra Fields as necessary
- $xml ="
- <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
- <listName>$listName</listName>
- <updates>
- <Batch ListVersion='1' OnError='Continue'>
- <Method Cmd='New' ID='1'>
- <Field Name='$field1Name'>$field1Value</Field>
- <Field Name='$field2Name'>$field2Value</Field>
- <Field Name='$field3Name'>$field3Value</Field>
- </Method>
- </Batch>
- </updates>
- </UpdateListItems>
- ";
- //Invoke the Web Service
- $result = $client->call('UpdateListItems', $xml);
- //Error check
- if(isset($fault)) {
- echo("<h2>Error</h2>". $fault);
- }
- //extracting the XML data from the SOAP response
- $responseContent = utf8_decode(htmlspecialchars(substr($client->response,strpos($client->response, "<"),strlen($client->response)-1), ENT_QUOTES));
- echo "<h2>Request</h2><pre>" . utf8_decode(htmlspecialchars($client->request, ENT_QUOTES)) . "</pre>";
- echo "<h2>Response header</h2><pre>" . utf8_decode(htmlspecialchars(substr($client->response,0,strpos($client->response, "<")))) . "</pre>";
- echo "<h2>Response content</h2><pre>".$responseContent."</pre>";
- //Debugging info:
- //echo("<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>");
- unset($client);
- ?>
- <?php
- include "ThybagSharePointAPI.php";
- include "ThybagAuthSharePointOnlineAuth.php";
- include "ThybagAuthSoapClientAuth.php";
- include "ThybagAuthStreamWrapperHttpAuth.php";
- include "ThybagServiceListService.php";
- include "ThybagServiceQueryObjectService.php";
- use ThybagSharePointAPI;
- $sp = new SharePointAPI('<user@domain.onmicrosoft.com>','<password>','<path_to_WSDL>,'SPONLINE'); //SPONLINE if your point is online else add true instead
- $data = $sp->read('Documents');
- var_dump($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement