Sharepoint 2010 Api - 故障代码:HTTPFault字符串:未经授权

时间:2014-12-01 06:50:08

标签: php sharepoint soap sharepoint-2010 wsdl

我使用以下代码获取sharepoint 2010 api的列表

    //Authentication details
$authParams = array('login' => "username",
                    'password' => 'password');
//// 
///* 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 surrounded by curly
// * braces ({}).
// */
$listName = "listname";
$rowLimit = '10';
// 
///* 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/sharepoint/Lists.asmx.xml";


$rawXMLresponse = null;
try{
//    //Creating the SOAP client and initializing the GetListItems method parameters
    $soapClient = new SoapClient($wsdl, $authParams);
    $params = array('listName' => $listName,
                'rowLimit' => $rowLimit);
    //Calling the GetListItems Web Service
    $rawXMLresponse = $soapClient->GetListItems($params)->GetListItemsResult->any;
}
catch(SoapFault $fault){
    echo 'Fault code: '.$fault->faultcode;
    echo 'Fault string: '.$fault->faultstring;
}
echo '<pre>' . $rawXMLresponse . '</pre>';

// 
////Loading the XML result into parsable DOM elements
$dom = new DOMDocument();
$dom->loadXML($rawXMLresponse);
$results = $dom->getElementsByTagNameNS("#RowsetSchema", "*");

//Fetching the elements values. Specify more attributes as necessary
foreach($results as $result){
    echo $result->getAttribute("ows_LinkTitle")."<br/>";
}
unset($soapClient);

并收到错误

    Fault code: HTTPFault string: Unauthorized

我使用了一些第三方库,例如https://github.com/thybag/PHP-SharePoint-Lists-API 但仍然没有运气。

任何人都参与其中,请建议我从共享点2010 api获取数据的方法

0 个答案:

没有答案