1

这个想法听起来很简单:将输入到 PHP 表单(我们使用 Drupal 7)中的数据提交到 SharePoint 2010。但我遇到了一些问题。

每个表单条目都应作为一个项目记录在 SharePoint 中,以便可以对其进行搜索和区分。所以我相信 SharePoint 列表或表单库会起作用。我只是缺乏使用 SharePoint 的经验,无法真正知道从哪里开始。

我想知道你如何相信这会奏效,如果有的话。

4

1 回答 1

2

这当然可以,您需要在 sharepoint 中创建一个列表,其中包含存储表单数据所需的列。然后从您的 PHP 代码中,您可以调用列表 Web 服务http://<site>/_vti_bin/Lists.asmx,并使用该UpdateListItems方法添加项目。

查看 MSDN 文档Lists Web ServiceLists.UpdateListItems MethodHow to: Update List Items,这些不使用 PHP,但您应该能够调整示例。

查询列表时,您需要使用 CAML 编写列表 Web 服务的查询,请参阅此SO 问题,了解一些有助于编写这些的工具。这些查询包含在SOAP您发送到 Web 服务的信封中。

我不知道 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);
?>
于 2013-09-26T09:39:24.613 回答