Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. <?php
  2.  
  3. // Requires the NuSOAP library
  4. require_once('lib/nusoap.php');
  5.  
  6. $username = 'yourUsername';
  7. $password = 'yourPassword';
  8. $rowLimit = '150';
  9.  
  10. /* A string that contains either the display name or the GUID for the list.
  11. * It is recommended that you use the GUID, which must be surrounded by curly
  12. * braces ({}).
  13. */
  14. $listName = "TempList";
  15.  
  16. /*
  17. * Example field (aka columns) names and values, that will be used in the
  18. * CAML query. The values are the attributes of a single list item here.
  19. * If the field name contains a space in SharePoint, replace it
  20. * here with _x0020_ (including underscores).
  21. */
  22. $field1Name = "Title";
  23. $field2Name = "Address";
  24. $field3Name = "Premium_x0020_customer";
  25.  
  26. $field1Value = "John Smith";
  27. $field2Value = "USA";
  28. $field3Value = "1";
  29.  
  30. /* Local path to the Lists.asmx WSDL file (localhost). You must first download
  31. * it manually from your SharePoint site (which should be available at
  32. * yoursharepointsite.com/subsite/_vti_bin/Lists.asmx?WSDL)
  33. */
  34. $wsdl = "http://localhost/phpsp/Lists.wsdl";
  35.  
  36. //Basic authentication is normally used when using a local copy a the WSDL. Using UTF-8 to allow special characters.
  37. $client = new nusoap_client($wsdl, true);
  38. $client->setCredentials($username,$password);
  39. $client->soap_defencoding='UTF-8';
  40.  
  41. //CAML query (request), add extra Fields as necessary
  42. $xml ="
  43. <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
  44. <listName>$listName</listName>
  45. <updates>
  46. <Batch ListVersion='1' OnError='Continue'>
  47. <Method Cmd='New' ID='1'>
  48. <Field Name='$field1Name'>$field1Value</Field>
  49. <Field Name='$field2Name'>$field2Value</Field>
  50. <Field Name='$field3Name'>$field3Value</Field>
  51. </Method>
  52. </Batch>
  53. </updates>
  54. </UpdateListItems>
  55. ";
  56.  
  57. //Invoke the Web Service
  58. $result = $client->call('UpdateListItems', $xml);
  59.  
  60. //Error check
  61. if(isset($fault)) {
  62. echo("<h2>Error</h2>". $fault);
  63. }
  64.  
  65. //extracting the XML data from the SOAP response
  66. $responseContent = utf8_decode(htmlspecialchars(substr($client->response,strpos($client->response, "<"),strlen($client->response)-1), ENT_QUOTES));
  67.  
  68. echo "<h2>Request</h2><pre>" . utf8_decode(htmlspecialchars($client->request, ENT_QUOTES)) . "</pre>";
  69. echo "<h2>Response header</h2><pre>" . utf8_decode(htmlspecialchars(substr($client->response,0,strpos($client->response, "<")))) . "</pre>";
  70. echo "<h2>Response content</h2><pre>".$responseContent."</pre>";
  71.  
  72. //Debugging info:
  73. //echo("<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>");
  74. unset($client);
  75. ?>
  76.  
  77. <?php
  78. include "ThybagSharePointAPI.php";
  79. include "ThybagAuthSharePointOnlineAuth.php";
  80. include "ThybagAuthSoapClientAuth.php";
  81. include "ThybagAuthStreamWrapperHttpAuth.php";
  82. include "ThybagServiceListService.php";
  83. include "ThybagServiceQueryObjectService.php";
  84. use ThybagSharePointAPI;
  85. $sp = new SharePointAPI('<user@domain.onmicrosoft.com>','<password>','<path_to_WSDL>,'SPONLINE'); //SPONLINE if your point is online else add true instead
  86. $data = $sp->read('Documents');
  87. var_dump($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement