From 6415adb09816fe50085324d8fe41a21b2c2780a7 Mon Sep 17 00:00:00 2001 From: Pieter Cappelle Date: Wed, 23 Dec 2015 21:54:44 +0100 Subject: [PATCH 1/9] SharePoint 2013 Tested and is working perfectly with SharePoint 2013. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c32ce60..e37de15 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ The **PHP SharePoint Lists API** is designed to make working with SharePoint Lis Using the PHP SharePoint Lists API, you can easily create, read, edit and delete from SharePoint list. The API also has support for querying list metadata and the list of lists. -Known to work with: SharePoint 2007 and SharePoint online (experimental). +Known to work with: SharePoint 2007, SharePoint 2013 and SharePoint online (experimental). ### Usage Instructions From 6c3176680c01904cc97901d0b46d844c2c2e39d9 Mon Sep 17 00:00:00 2001 From: fernandosantini Date: Wed, 10 Feb 2016 17:33:03 -0200 Subject: [PATCH 2/9] "Like" operator Adding "like" operator to be used on where clause method --- src/Thybag/Service/QueryObjectService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Thybag/Service/QueryObjectService.php b/src/Thybag/Service/QueryObjectService.php index c8ccdbd..281f6bd 100644 --- a/src/Thybag/Service/QueryObjectService.php +++ b/src/Thybag/Service/QueryObjectService.php @@ -216,21 +216,21 @@ public function get ($options = NULL) { * * @param $rel Relation AND/OR etc * @param $col column to test - * @param $test comparison type (=,!+,<,>) + * @param $test comparison type (=,!+,<,>,like) * @param $value value to test with * @return Ref to self * @throws \Exception Thrown if $test is unrecognized */ private function addQueryLine ($rel, $col, $test, $value) { // Check tests are usable - if (!in_array($test, array('!=', '>=', '<=', '<', '>', '='))) { - throw new \Exception('Unrecognized query parameter. Please use <,>,=,>=,<= or !='); + if (!in_array($test, array('!=', '>=', '<=', '<', '>', '=', 'like'))) { + throw new \Exception('Unrecognized query parameter. Please use <,>,=,>=,<=, != or like'); } // Make sure $rel is lower-case $rel = strtolower($rel); - $test = str_replace(array('!=', '>=', '<=', '<', '>', '='), array('Neq', 'Geq', 'Leq', 'Lt', 'Gt', 'Eq'), $test); + $test = str_replace(array('!=', '>=', '<=', '<', '>', '=', 'like'), array('Neq', 'Geq', 'Leq', 'Lt', 'Gt', 'Eq', 'Contains'), $test); // Create caml $caml = $this->where_caml; @@ -291,4 +291,4 @@ public function getOptionCAML () { return $xml; } -} \ No newline at end of file +} From 62148061d15864e51eae53bbb2141c479c3af732 Mon Sep 17 00:00:00 2001 From: thybag Date: Wed, 2 Mar 2016 22:12:01 +0000 Subject: [PATCH 3/9] Remove hardcoded debug options on CURL --- src/Thybag/Auth/SoapClientAuth.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Thybag/Auth/SoapClientAuth.php b/src/Thybag/Auth/SoapClientAuth.php index 0a8e30b..1e8b698 100644 --- a/src/Thybag/Auth/SoapClientAuth.php +++ b/src/Thybag/Auth/SoapClientAuth.php @@ -109,8 +109,6 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_VERBOSE, TRUE); - curl_setopt($ch, CURLOPT_CERTINFO, TRUE); $response = curl_exec($ch); From 77ed7908227234ad37126919ba98f2dd383beea1 Mon Sep 17 00:00:00 2001 From: thybag Date: Wed, 2 Mar 2016 22:33:24 +0000 Subject: [PATCH 4/9] Add additional SoapAction header to SPonline requests - credit to @makarandchavan for this fix --- src/Thybag/Auth/SharePointOnlineAuth.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Thybag/Auth/SharePointOnlineAuth.php b/src/Thybag/Auth/SharePointOnlineAuth.php index d1d150e..941bb4b 100644 --- a/src/Thybag/Auth/SharePointOnlineAuth.php +++ b/src/Thybag/Auth/SharePointOnlineAuth.php @@ -22,6 +22,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = f // Set base headers $headers = array(); $headers[] = "Content-Type: text/xml;"; + $headers[] = "SOAPAction: \"{$action}\""; $curl = curl_init($location); @@ -43,7 +44,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = f // Failure to have this will result in a "Security Validation exception" // @see http://weblogs.asp.net/jan/archive/2009/05/25/quot-the-security-validation-for-this-page-is-invalid-quot-when-calling-the-sharepoint-web-services.aspx if( strpos($request, 'UpdateListItems') !== FALSE ) { - $headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"'; + $headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"'; } // Add headers From e12a72b6849fd3e3d232588e5c9eedac956b0d4b Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Fri, 29 Apr 2016 13:02:47 -0400 Subject: [PATCH 5/9] Call loadXML with the LIBXML_PARSEHUGE option if running a version of DOMDocument that supports it. --- src/Thybag/SharePointAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Thybag/SharePointAPI.php b/src/Thybag/SharePointAPI.php index 51d7759..717fe98 100644 --- a/src/Thybag/SharePointAPI.php +++ b/src/Thybag/SharePointAPI.php @@ -772,7 +772,7 @@ public function CRUD ($list_name) { private function getArrayFromElementsByTagName ($rawXml, $tag, $namespace = NULL) { // Get DOM instance and load XML $dom = new \DOMDocument(); - $dom->loadXML($rawXml); + $dom->loadXML($rawXml, (LIBXML_VERSION >= 20900) ? LIBXML_PARSEHUGE : null); // Is namespace set? if (!is_null($namespace)) { From 6c0773d8bc7819804ad869af2984c7bc76c090fa Mon Sep 17 00:00:00 2001 From: thybag Date: Tue, 19 Jul 2016 20:32:14 +0100 Subject: [PATCH 6/9] Use LIBXML_PARSEHUGE when possible. https://github.com/thybag/PHP-SharePoint-Lists-API/issues/102 --- src/Thybag/SharePointAPI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Thybag/SharePointAPI.php b/src/Thybag/SharePointAPI.php index 51d7759..b6b3f6e 100644 --- a/src/Thybag/SharePointAPI.php +++ b/src/Thybag/SharePointAPI.php @@ -772,7 +772,7 @@ public function CRUD ($list_name) { private function getArrayFromElementsByTagName ($rawXml, $tag, $namespace = NULL) { // Get DOM instance and load XML $dom = new \DOMDocument(); - $dom->loadXML($rawXml); + $dom->loadXML($rawXmlk, LIBXML_VERSION >= 20900 ? LIBXML_PARSEHUGE : null); // Is namespace set? if (!is_null($namespace)) { @@ -1096,7 +1096,7 @@ public function getFieldVersions ($list, $id, $field) { // Load XML in to DOM document and grab all Fields $dom = new \DOMDocument(); - $dom->loadXML($rawxml); + $dom->loadXML($rawxml, LIBXML_VERSION >= 20900 ? LIBXML_PARSEHUGE : null); $nodes = $dom->getElementsByTagName("Version"); // Parse results From 83876e8f9613362c2fc9f18d2948a73d2d5c1a5a Mon Sep 17 00:00:00 2001 From: thybag Date: Tue, 19 Jul 2016 20:38:45 +0100 Subject: [PATCH 7/9] Remove duplicate soap action on update lists for SPOnline (see: https://github.com/thybag/PHP-SharePoint-Lists-API/issues/105 ) --- src/Thybag/Auth/SharePointOnlineAuth.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Thybag/Auth/SharePointOnlineAuth.php b/src/Thybag/Auth/SharePointOnlineAuth.php index 941bb4b..9e63256 100644 --- a/src/Thybag/Auth/SharePointOnlineAuth.php +++ b/src/Thybag/Auth/SharePointOnlineAuth.php @@ -40,13 +40,6 @@ public function __doRequest($request, $location, $action, $version, $one_way = f curl_setopt($curl, CURLOPT_VERBOSE,FALSE); curl_setopt($curl, CURLOPT_HEADER, FALSE); - // SharePoint Online requires the SOAPAction header set for ADD/EDIT and DELETE Operations. - // Failure to have this will result in a "Security Validation exception" - // @see http://weblogs.asp.net/jan/archive/2009/05/25/quot-the-security-validation-for-this-page-is-invalid-quot-when-calling-the-sharepoint-web-services.aspx - if( strpos($request, 'UpdateListItems') !== FALSE ) { - $headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"'; - } - // Add headers curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); From 4393e1af30551940f1e66e0b7d9a124a36e32b85 Mon Sep 17 00:00:00 2001 From: jecastro Date: Fri, 26 May 2017 17:31:53 -0300 Subject: [PATCH 8/9] fix: url with blank spaces --- src/Thybag/Auth/SoapClientAuth.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Thybag/Auth/SoapClientAuth.php b/src/Thybag/Auth/SoapClientAuth.php index 1e8b698..4f384f5 100644 --- a/src/Thybag/Auth/SoapClientAuth.php +++ b/src/Thybag/Auth/SoapClientAuth.php @@ -92,6 +92,8 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 ); $this->__last_request_headers = $headers; + $location = $this->sanitizeUrl($location); + $ch = curl_init($location); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); @@ -129,4 +131,14 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 } } } + + /** + * Sanitize URL to request to Sharepoint + * + * @param string $url + * @return type string + */ + protected function sanitizeUrl($url) { + return str_replace(" ", "%20", $url); + } } From 0dd10ccf10ccd7590efdc7616775b2416dd7e076 Mon Sep 17 00:00:00 2001 From: Carl Date: Fri, 6 Jul 2018 18:09:18 +0100 Subject: [PATCH 9/9] No longer set version via composer - let packagist handle --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 7c70520..b7b3bc2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "thybag/php-sharepoint-lists-api", - "version": "0.6.4", "type": "library", "description": "A simple PHP API to make working with SharePoint lists easy.", "homepage": "https://github.com/thybag/PHP-SharePoint-Lists-API",