簡體   English   中英

將PHP表單導入SharePoint 2010

[英]PHP form into SharePoint 2010

這個想法聽起來很簡單:將輸入到PHP表單(我們使用Drupal 7)中的數據提交到SharePoint 2010中。但是我在解決該問題時遇到了一些問題。

每個表單條目都應作為一項記錄在SharePoint中,以便可以在其中進行搜索和區分。 因此,我相信SharePoint列表或表單庫將起作用。 我只是缺乏與SharePoint的經驗,無法真正知道從哪里開始。

我想知道您如何認為這行得通。

這當然可以工作,您需要在sharepoint中創建一個列表,其中包含必要的列以存儲表單數據。 然后,從PHP代碼中,可以調用列表Web服務http://<site>/_vti_bin/Lists.asmx然后可以使用UpdateListItems方法添加項目。

看看MSDN文檔列表Web服務Lists.UpdateListItems方法如何:更新列表項 ,這些都不使用PHP,但是您應該可以修改示例。

查詢列表時,您將需要使用CAML編寫針對列表Web服務的查詢,請參閱此SO問題以獲取一些有助於編寫這些工具的工具。 這些查詢被包裝在發送到Web服務的SOAP信封中。

我不知道PHP,但是下面的引號和代碼來自David的IT博客-使用PHP創建SharePoint列表項

要使代碼正常工作,您將需要NuSOAP庫,您自己的本地Lists WSDL文件,當然還需要在下面的代碼中擁有自己的個性化身份驗證/列表變量。 此代碼已通過SharePoint Online和PHP 5.3進行了測試,但應與MOSS 2007一起使用。

<?php

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

$username = 'yourUsername';
$password = 'yourPassword';
$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 surrounded by curly
 * braces ({}).
 */
$listName = "TempList";

/*
 * Example field (aka columns) names and values, that will be used in the
 * CAML query. The values are the attributes of a single list item here.
 * If the field name contains a space in SharePoint, replace it
 * here with _x0020_ (including underscores).
 */
$field1Name = "Title";
$field2Name = "Address";
$field3Name = "Premium_x0020_customer";

$field1Value = "John Smith";
$field2Value = "USA";
$field3Value = "1";

/* 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/phpsp/Lists.wsdl";

//Basic authentication is normally used when using a local copy a the WSDL. Using UTF-8 to allow special characters.
$client = new nusoap_client($wsdl, true);
$client->setCredentials($username,$password);
$client->soap_defencoding='UTF-8';

//CAML query (request), add extra Fields as necessary
$xml ="
 <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
 <listName>$listName</listName>
 <updates>
 <Batch ListVersion='1' OnError='Continue'>
 <Method Cmd='New' ID='1'>
 <Field Name='$field1Name'>$field1Value</Field>
 <Field Name='$field2Name'>$field2Value</Field>
 <Field Name='$field3Name'>$field3Value</Field>
 </Method>
 </Batch>
 </updates>
 </UpdateListItems>
";

//Invoke the Web Service
$result = $client->call('UpdateListItems', $xml);

//Error check
if(isset($fault)) {
 echo("<h2>Error</h2>". $fault);
}

//extracting the XML data from the SOAP response
$responseContent = utf8_decode(htmlspecialchars(substr($client->response,strpos($client->response, "<"),strlen($client->response)-1), ENT_QUOTES));

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>";

//Debugging info:
//echo("<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>");
unset($client);
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM