diff --git a/src/Thybag/Auth/SharePointOnlineAuth.php b/src/Thybag/Auth/SharePointOnlineAuth.php
index 9dc04fd..3c6f457 100644
--- a/src/Thybag/Auth/SharePointOnlineAuth.php
+++ b/src/Thybag/Auth/SharePointOnlineAuth.php
@@ -32,7 +32,8 @@ public function __doRequest($request, $location, $action, $version, $one_way = f
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_COOKIE, $this->authCookies);
- curl_setopt($curl, CURLOPT_TIMEOUT, 10);
+ curl_setopt($curl, CURLOPT_SSLVERSION, 4);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 100);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
// Useful for debugging
@@ -45,6 +46,9 @@ public function __doRequest($request, $location, $action, $version, $one_way = f
if( strpos($request, 'UpdateListItems') !== FALSE ) {
$headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"';
}
+ if( strpos($request, 'CopyIntoItems') !== FALSE ) {
+ $headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"';
+ }
// Add headers
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@@ -89,7 +93,7 @@ protected function configureAuthCookies($location) {
// Send request and grab returned xml
$result = $this->authCurl("https://login.microsoftonline.com/extSTS.srf", $xml);
-
+
// Extract security token from XML
$xml = new \DOMDocument();
$xml->loadXML($result);
@@ -143,7 +147,7 @@ protected function extractAuthCookies($result){
$authCookies[] = $loop[1];
}
}
- unset($authCookies[0]); // No need for first cookie
+ //unset($authCookies[0]); // No need for first cookie
// Extract cookie name & payload and format in to cURL compatible string
foreach($authCookies as $payload){
@@ -180,9 +184,9 @@ protected function authCurl($url, $payload, $header = false){
curl_setopt($ch,CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
+ curl_setopt($ch, CURLOPT_SSLVERSION, 4);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 100);
if($header) curl_setopt($ch, CURLOPT_HEADER, true);
@@ -240,4 +244,4 @@ protected function generateSecurityToken($username, $password, $endpoint) {
TOKEN;
}
-}
\ No newline at end of file
+}
diff --git a/src/Thybag/SharePointAPI.php b/src/Thybag/SharePointAPI.php
index 6d22999..ae7eade 100644
--- a/src/Thybag/SharePointAPI.php
+++ b/src/Thybag/SharePointAPI.php
@@ -1127,4 +1127,71 @@ public function getColumnVersions ($list, $id, $field) { return $this->getFieldV
public function getVersions ($list, $id, $field = null) {
return $this->getFieldVersions($list, $id, $field);
}
+
+
+ public function copyIntoItems ($destinationUrl, $file_path, array $fields = null) {
+ // base64 encode file
+ $file_info = pathinfo($file_path);
+
+ $file_name = $file_info['basename'];
+ $destinationUrl = $destinationUrl . $file_name;
+
+ $attachment = base64_encode(file_get_contents($file_path));
+
+ // Wrap in CAML
+ $CAML = '
+ '.$file_name.'
+
+ '.$destinationUrl.'
+ ';
+ if($fields!=null && count($fields)>0)
+ {
+ $CAML .= ' ';
+ for ($i = 0; $i < count($fields); ++$i) {
+ $CAML .= ' $value) {
+ $CAML .= " ".$key."=\"".$value."\"";
+
+ }
+ $CAML .= ' />';
+ }
+
+ $CAML .= ' ';
+ }
+ $CAML .= '
+ ' . $attachment . '
+ ';
+
+ $xmlvar = new \SoapVar($CAML, XSD_ANYXML);
+
+ // Attempt to run operation
+ try {
+ return $this->soapClient->CopyIntoItems($xmlvar);
+ } catch (\SoapFault $fault) {
+ $this->onError($fault);
+ }
+
+ // Return true on success
+ return null;
+ }
+
+ public function getItem ($sourceUrl) {
+
+ // Wrap in CAML
+ $CAML = '
+ '.$sourceUrl.'
+ ';
+
+ $xmlvar = new \SoapVar($CAML, XSD_ANYXML);
+
+ // Attempt to run operation
+ try {
+ return $this->soapClient->GetItem($xmlvar);
+ } catch (\SoapFault $fault) {
+ $this->onError($fault);
+ }
+
+ // Return true on success
+ return null;
+ }
}
\ No newline at end of file