有谁知道如何集成Sharepoint和Php。我正在尝试开发一个php应用程序,可以连接到Sharepoint。特别是因为我基本上是一个网站开发人员,我希望我的所有网站都与Sharepoint相连。所以,简单地说,我想创建一个Php应用程序,使其适用于所有网站。我不知道这是否可能,但我想尝试一下,但不知道如何继续。
欢迎任何想法/建议。
提前感谢您。
有谁知道如何集成Sharepoint和Php。我正在尝试开发一个php应用程序,可以连接到Sharepoint。特别是因为我基本上是一个网站开发人员,我希望我的所有网站都与Sharepoint相连。所以,简单地说,我想创建一个Php应用程序,使其适用于所有网站。我不知道这是否可能,但我想尝试一下,但不知道如何继续。
欢迎任何想法/建议。
提前感谢您。
SoapClientAuth.php
和SharePointAPI.php
在PHP中:// 0: include api in your php script.
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);
}
$listContents = $sp->read('<list_name>');
时,出现了 未授权 的错误。你有什么想法吗? - HeinrichStack$sp = new SharePointAPI('<username>', '<password>', '<path_to_WSDL>', true);
注意最后一个参数是 true。 - NoodleFolkSPONLINE
。
new SharePointAPI('xx', 'yy', 'zz', 'SPONLINE');
- Vincent Poiriersharepoint.url/subsite/_vti_bin/Lists.asmx?WSDL
如果您正在使用composer,请将thybag/php-sharepoint-lists-api添加到您的composer.json中,并运行composer。 {
"require": {
"thybag/php-sharepoint-lists-api": "dev-master"
}
}
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '');
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '', 'NTLM');
SharePoint Online用户必须使用:
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '', 'SPONLINE');
$sp->read('');
or
$sp->query('')->get();
要仅返回列表中的前10个项目,请使用:
$sp->read('', 10);
或者
$sp->query('')->limit(10)->get();
要返回姓氏为Smith的列表中的所有项目,请使用:
$sp->read('', NULL, array('surname'=>'smith'));
或者
$sp->query('')->where('surname', '=', 'smith')->get();
查询列表
当您需要指定一个复杂的查询,无法使用读取方法轻松定义时,可以使用查询方法。查询是使用许多(希望表达清晰)伪 SQL 方法构建的。
例如,如果您想查询一组宠物,并返回所有年龄低于5岁的狗(按年龄排序),则可以使用以下方法。
$sp->query('list of pets')->where('type','=','dog')->and_where('age','sort('age','ASC')->get();
$sp->query('list of pets')->where('type','=','cat')->or_where('type','=','hamster')->limit(10)->get();
$sp->query('list of pets')->all_fields()->get();
$sp->query('list of pets')->raw_where('Hello World')->limit(10)->get();
添加到列表
要将新项目添加到列表中,您可以使用“write”,“add”或“insert”方法(所有函数的功能相同)。在具有名字、姓氏、年龄和电话列的列表中创建新记录可能如下所示:
$sp->write('', array('forename'=>'Bob','surname' =>'Smith', 'age'=>40, 'phone'=>'(00000) 000000' ));
您也可以使用以下方法同时运行多个写操作:
$sp->writeMultiple('', array(array('forename' => 'James'),array('forename' => 'Steve')));
编辑行
要编辑一行,需要知道它的ID。假设上面的一行的ID为5,我们可以用以下代码将Bob的姓名更改为James:
$sp->update('','5', array('forename'=>'James'));/code>
$sp->updateMultiple('', array( array('ID'=>5,'job'=>'Intern'),array('ID'=>6,'job'=>'Intern')));
使用updateMultiple时,每个项目都必须有一个ID。
删除行
要删除一行,需要提供ID和列表名称。要删除ID为5的James记录,您需要使用:
$sp->delete('', '5');
$sp->deleteMultiple('', array('6','7','8'));
辅助方法
PHP SharePoint API包含许多辅助方法,使得确保某些SharePoint特殊数据类型的值处于正确格式更容易。
dateTime DateTime方法可以传递基于文本的日期。
$date = \Thybag\SharepointApi::dateTime("2012-12-21");
或者是Unix时间戳
$date = \Thybag\SharepointApi::dateTime(time(), true);
故障排除
无法找到包装器 "https"
如果您遇到此错误,通常意味着您的 Web 服务器未启用 php_openssl(需要用于 curl https URL)。对于许多本地 Web 服务器(例如 XAMPP),您可以简单地打开您的 php.ini 文件并取消注释 php_openssl 行(即删除其前面的;)。
注意:如果您正在使用 SharePoint Online 并且遇到 SSL 错误,请拉取最新版本,该版本已从 SSL v3 更改为 TLS 以用于 SharePoint 在线连接。
将此行添加到您的 composer.json 文件中
thybag/php-sharepoint-lists-api: dev-develop
您可以使用上述 SharePoint API 执行 CRUD(创建/读取/更新/删除)操作。
参考 URL 链接:https://github.com/thybag/PHP-SharePoint-Lists-API
除了关于一个叫做Camelot PHP的工具的讨论在这里。