How to connect sharepoint to php

Does anyone know how to integrate Sharepoint and Php. I am trying to develop a php application that can connect to Sharepoint. In particular, since I'm primarily a website developer, I want all my sites to be linked to Sharepoint. Therefore, I just want to create a Php application so that it works for all websites. I don’t know if this is possible or not, but I want to try, but I don’t know how to proceed.

Any idea / suggestions are welcome.

Thanks in advance.

+7
soap php sharepoint sharepoint-2013
source share
4 answers

Try the API

In SharePoint

Download WSDL. Usually in this place: <sharepoint.url> /subsite/_vti_bin/Lists.asmx? Wsdl

Download API

Be sure to save both SoapClientAuth.php and SharePointAPI.php

In php

 // 0: include api in your PHP . require_once('SharePointAPI.php'); // 1: connect to SharePoint $sp = new SharePointAPI('<username>', '<password>', '<path_to_WSDL>'); // 2: read a list $listContents = $sp->read('<list_name>'); // 3: now you have a 2-D array to work with in PHP foreach($listContents as $item) { var_dump($item); } 

Using this API you can also request, update, create, delete lists, query list metadata

+8
source share

If I read your question correctly, you want to interact with your SharePoint site using PHP. You can do most of the interaction with SharePoint Web Services. For example, you can read all list items using the list web service (http: ///_vti_bin/lists.asmx). You can upload files to a SharePoint document library. I furiously searched for an example of what I did to achieve this, but I lost it. I remember using Curl to load.

There are several sites that discuss using PHP to access SharePoint data. Here is a couple I found using a simple google search:

As well as a discussion of a tool called Camelot PHP here

+1
source share

I used this in the API to connect my PHP web application to SharePoint and transfer data from PHP to SharePoint, for me it worked 100%:

Instructions for use :

Installation

Download the WSDL file for the SharePoint lists you want to interact with. This can usually be obtained at: sharepoint.url/subsite/_vti_bin/Lists.asmx?WSDL

If you are using composer, just add thybag / php-sharepoint-lists-api to your composer.json and run composer.

  { "require": { "thybag/php-sharepoint-lists-api": "dev-master" } } 

If you are not using composer, you can manually download a copy of the SharePoint API files and include the top class "SharePointAPI.php" in your project.

Create a SharePointAPI Object

To use the PHP SharePoint List APIs, you need a valid user / service account with the permissions for the required list.

For most SharePoint installations, you can create a new instance of the API using:

  use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', ''); 

If your installation requires NTLM authentication, you can use:

  use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', '', 'NTLM'); 

SharePoint Online users should use:

  use Thybag\SharePointAPI; $sp = new SharePointAPI('', '', '', 'SPONLINE'); 

All methods return an array by default. SetReturnType can be used to indicate that results should be returned as objects.

Reading from the list.

To return all items from a list, use either

  $sp->read(''); 
 or 
  $sp->query('')->get(); 

To return only the first 10 items from a list, use:

  $sp->read('', 10); 

or

  $sp->query('')->limit(10)->get(); 

To return all items from a list where Smith's last name is, use:

  $sp->read('', NULL, array('surname'=>'smith')); 

or

  $sp->query('')->where('surname', '=', 'smith')->get(); 

List request

You can use the query method when you need to specify a complex query that can be easily determined using read methods. Queries are built using a number of (hopefully expressive) pseudo SQL methods.

For example, if you want to request a list of pets and return all dogs under 5 years of age (sorted by age), you can use them.

 $sp->query('list of pets')->where('type','=','dog')->and_where('age','sort('age','ASC')->get(); 

If you want to get the first 10 animals that were cats or hamsters, you can use:

  $sp->query('list of pets')->where('type','=','cat')->or_where('type','=','hamster')->limit(10)->get(); 

If you need to return 5 items, but including all the fields contained in the list, you can use. (pass false to all_fields to enable hidden fields).

  $sp->query('list of pets')->all_fields()->get(); 

If you have a CAML set for a specific extended request that you want to execute, you can pass it to the request object using:

  $sp->query('list of pets')->raw_where('Hello World')->limit(10)->get(); 

Add to list

To add a new item to the list, you can use the "write", "add" or "insert" method (all functions are the same). Creating a new entry in the list with the columns first name, last name, age and phone may look like this:

  $sp->write('', array('forename'=>'Bob','surname' =>'Smith', 'age'=>40, 'phone'=>'(00000) 000000' )); 

You can also start several write operations using:

  $sp->writeMultiple('', array(array('forename' => 'James'),array('forename' => 'Steve'))); 

Line editing

To edit a line you need to have its identifier. Assuming the above line has an identifier of 5, we can change Bob's name to James with:

  $sp->update('','5', array('forename'=>'James'));/code> 

As with the write method you can also run multiple update operations together by using:

  $sp->updateMultiple('', array( array('ID'=>5,'job'=>'Intern'),array('ID'=>6,'job'=>'Intern'))); 

When using updateMultiple, each element MUST have an identifier.

Delete lines

To delete a line, an identifier is required, as well as a list name. To delete an entry for James with id 5, you should use:

  $sp->delete('', '5'); 

If you want to delete several records at once, the ID array can also be passed to several delete methods

  $sp->deleteMultiple('', array('6','7','8')); 

Helper Methods

The PHP SharePoint API contains several helper methods that make it easy to ensure that certain values ​​have the correct format for some special SharePoint data types.

dateTime You can pass a text date to the DateTime method

  $date = \Thybag\SharepointApi::dateTime("2012-12-21"); 

Or Unix timestamp

  $date = \Thybag\SharepointApi::dateTime(time(), true); 

Problem finding

Unable to find wrapper "https"

If you get this error, it usually means that php_openssl (needed to curl https URLs) is not enabled on your web server. On many local web servers (such as XAMPP), you can simply open the php.ini file and uncomment the php_openssl line (i.e. delete; in front of it).

Note. If you are using SharePoint Online and are having SSL errors, install the latest version that has been changed from SSL v3 to TLS for SharePoint online connections.

Add this line to your composer.json file

  thybag / php-sharepoint-lists-api: dev-develop 

You can perform a CRUD operation (create / read / update / delete) using the above SharePoint API.

Link URL link: https://github.com/thybag/PHP-SharePoint-Lists-API

+1
source share

This does not work for me. This makes a lot of mistakes.


src / Thybag / SharePointAPI.php Note: Using the undefined constant SOAP_1_1 - assumes SOAP_1_1 in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ home.php on line 6

Please note: using the undefined constant WSDL_CACHE_NONE - it is assumed that WSDL_CACHE_NONE is in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ home.php on line 6

Warning: include_once (src / SoapClient.php): stream could not be opened: there is no such file or directory in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ SharePointAPI.php on line 25

Warning: include_once (): could not open src / SoapClient.php file to include (include_path = 'C: \ xampp \ php \ PEAR') in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API-development \ SharePointAPI .php on line 25 src / SoapClient.php Warning: assert (): assertion failed in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ src \ Thybag \ SharePointAPI.php on line 144

Warning: include_once (src / SoapClient.php): stream could not be opened: there is no such file or directory in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ SharePointAPI.php on line 25

Warning: include_once (): could not open src / SoapClient.php file to include (include_path = 'C: \ xampp \ php \ PEAR') in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API-development \ SharePointAPI .php on line 25 src / SoapClient.php Fatal error: class 'SoapClient' not found in C: \ xampp \ htdocs \ PHP-SharePoint-Lists-API -velop \ src \ Thybag \ Auth \ SharePointOnlineAuth.php on line 11

-one
source share

All Articles