0

I am new to SharePoint . I'm trying to access SharePoint list via PHP. I am able to connect to SharePoint which means my app is authenticating but not able access list data.

ERROR THROWN IS:

List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user

<?php

//Requires the NuSOAP library
require_once('lib/nusoap.php');

$username = 'my_user_name';
$password = 'my_password';
$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 between curly
 * braces ({}).
 */
$listName = "Custom App_3";

/* 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/share_point_php/Soap/SharePointAPI.wsdl";

//Basic authentication. Using UTF-8 to allow special characters.
$client = new nusoap_client($wsdl, true);

 $client->setCredentials($username,$password);
$client->soap_defencoding='UTF-8';

//XML for the request. Add extra fields as necessary
$xml ='
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>'.$listName.'</listName>
<rowLimit>'.$rowLimit.'</rowLimit>
</GetListItems>
';

//Invoke the Web Service
$result = $client->call('GetListItems', $xml);
 var_dump($result);
//Error check
if(isset($fault)) {
  echo("[![<h2>][1]][1]Error</h2>". $fault);
}

//Extracting and preparing the Web Service response for display
$responseContent = utf8_decode(htmlspecialchars(substr($client->response,strpos($client->response, "<"),strlen($client->response)-1)));

//Displaying the request and the response, broken down by header and XML content
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>";

//Uncomment for debugging info:
//echo("<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>");
unset($client);
?>
10
  • Can you paste your code? Sep 26, 2016 at 12:07
  • @jpussacq please refer Edited Post
    – Arun A T
    Sep 26, 2016 at 12:22
  • Did you check permissions for user your are using? Sep 26, 2016 at 13:22
  • @jpussacq I'm loging in as administrator.It has full control.and even I have given the read permission also.
    – Arun A T
    Sep 26, 2016 at 13:30
  • where are you setting de sharepoint url site? Sep 26, 2016 at 14:50

1 Answer 1

1

Try this api: https://github.com/thybag/PHP-SharePoint-Lists-API

I have tried and it works perfectly. you can also find how to's of the api on same link.

<?php include "Thybag\SharePointAPI.php"; include "Thybag\Auth\SharePointOnlineAuth.php"; include "Thybag\Auth\SoapClientAuth.php"; include "Thybag\Auth\StreamWrapperHttpAuth.php"; include "Thybag\Service\ListService.php"; include "Thybag\Service\QueryObjectService.php"; use Thybag\SharePointAPI; $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);

This will return you the array of all lists stored on sharepoint. Then based on your need you can get the file name by calling array from the above array list.

2
  • Please provide detailed description in answer. If link breaks down in future, then answer will be useless. Jan 11, 2017 at 10:12
  • Updated my Answer @DikeshGandhi
    – darkrider
    Jan 11, 2017 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.