PHP SharePoint Lists API 技术文档
1. 安装指南
使用 Composer 安装
如果你使用 Composer,只需将 thybag/php-sharepoint-lists-api 添加到你的 composer.json 文件中,然后运行 composer install。
{
"require": {
"thybag/php-sharepoint-lists-api": "dev-master"
}
}
手动安装
如果你不使用 Composer,可以手动下载 SharePointAPI 文件,并在你的项目中包含顶层的 SharePointAPI.php 类。
2. 项目的使用说明
创建 SharePointAPI 对象
在使用 PHP SharePoint Lists API 之前,你需要一个具有所需列表权限的有效用户/服务账户。
对于大多数 SharePoint 安装,你可以使用以下方式创建 API 实例:
use Thybag\SharePointAPI;
$sp = new SharePointAPI('<username>', '<password>', '<path_to_WSDL>');
如果你的安装需要 NTLM 认证,可以使用以下方式:
use Thybag\SharePointAPI;
$sp = new SharePointAPI('<username>', '<password>', '<path_to_WSDL>', 'NTLM');
SharePoint Online 用户必须使用以下方式:
use Thybag\SharePointAPI;
$sp = new SharePointAPI('<username>', '<password>', '<path_to_WSDL>', 'SPONLINE');
所有方法默认返回数组。可以使用 SetReturnType 指定结果应作为对象返回。
3. 项目API使用文档
读取列表数据
返回列表中的所有项目
$sp->read('<list_name>');
或
$sp->query('<list_name>')->get();
返回列表中的前10项
$sp->read('<list_name>', 10);
或
$sp->query('<list_name>')->limit(10)->get();
返回姓氏为 "smith" 的所有项目
$sp->read('<list_name>', NULL, array('surname'=>'smith'));
或
$sp->query('<list_name>')->where('surname', '=', 'smith')->get();
返回姓氏为 "smith" 且年龄为 40 的前5项
$sp->read('<list_name>', 5, array('surname'=>'smith','age'=>40));
或
$sp->query('<list_name>')->where('surname', '=', 'smith')->and_where('age', '=', '40')->limit(5)->get();
使用特定视图返回姓氏为 "smith" 的前10项
$sp->read('<list_name>', 10, array('surname'=>'smith','age'=>40),'{0FAKE-GUID001-1001001-10001}');
或
$sp->query('<list_name>')->where('surname', '=', 'smith')->and_where('age', '=', '40')->limit(10)->using('{0FAKE-GUID001-1001001-10001}')->get();
返回姓氏为 "smith" 且按年龄排序的前10项
$sp->read('<list_name>', 10, array('surname'=>'smith'), NULL, array('age' => 'desc'));
或
$sp->query('<list_name>')->where('surname', '=', 'smith')->limit(10)->sort('age','DESC')->get();
返回前5项,包括 "favroite_cake" 和 "favorite_animal" 列
$sp->read('<list_name>', 5, NULL, array("favroite_cake", "favorite_animal"));
或
$sp->query('<list_name>')->fields(array("favroite_cake", "favorite_animal"))->limit(5)->get();
查询列表
查询方法可以用于需要指定复杂查询的情况。查询是通过一系列(希望是表达性的)伪 SQL 方法构建的。
例如,如果你想查询一个宠物列表并返回所有年龄小于5岁的狗(按年龄排序),你可以使用:
$sp->query('list of pets')->where('type','=','dog')->and_where('age','<','5')->sort('age','ASC')->get();
如果你想获取前10个宠物,它们要么是猫要么是仓鼠,你可以使用:
$sp->query('list of pets')->where('type','=','cat')->or_where('type','=','hamster')->limit(10)->get();
添加到列表
要向列表中添加新项目,可以使用 write、add 或 insert 方法(所有方法功能相同)。创建一个包含 forename、surname、age 和 phone 列的新记录可能如下所示:
$sp->write('<list_name>', array('forename'=>'Bob','surname' =>'Smith', 'age'=>40, 'phone'=>'(00000) 000000' ));
你还可以通过以下方式一起运行多个写操作:
$sp->writeMultiple('<list_name>', array(
array('forename' => 'James'),
array('forename' => 'Steve')
));
编辑行
要编辑一行,你需要其 ID。假设上面的行有 ID 5,我们可以将 Bob 的名字改为 James:
$sp->update('<list_name>','5', array('forename'=>'James'));
与 write 方法一样,你也可以通过以下方式一起运行多个更新操作:
$sp->updateMultiple('<list_name>', array(
array('ID'=>5,'job'=>'Intern'),
array('ID'=>6,'job'=>'Intern')
));
删除行
要删除一行,需要其 ID 和列表名称。要删除 ID 为 5 的 James 记录,你可以使用:
$sp->delete('<list_name>', '5');
如果你希望一次删除多个记录,也可以将 ID 数组传递给 deleteMultiple 方法:
$sp->deleteMultiple('<list_name>', array('6','7','8'));
4. 项目安装方式
使用 Composer 安装
{
"require": {
"thybag/php-sharepoint-lists-api": "dev-master"
}
}
手动安装
手动下载 SharePointAPI 文件,并在你的项目中包含顶层的 SharePointAPI.php 类。
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust099- DDeepSeek-V4-ProDeepSeek-V4-Pro(总参数 1.6 万亿,激活 49B)面向复杂推理和高级编程任务,在代码竞赛、数学推理、Agent 工作流等场景表现优异,性能接近国际前沿闭源模型。Python00
MiMo-V2.5-ProMiMo-V2.5-Pro作为旗舰模型,擅⻓处理复杂Agent任务,单次任务可完成近千次⼯具调⽤与⼗余轮上 下⽂压缩。Python00
GLM-5.1GLM-5.1是智谱迄今最智能的旗舰模型,也是目前全球最强的开源模型。GLM-5.1大大提高了代码能力,在完成长程任务方面提升尤为显著。和此前分钟级交互的模型不同,它能够在一次任务中独立、持续工作超过8小时,期间自主规划、执行、自我进化,最终交付完整的工程级成果。Jinja00
Kimi-K2.6Kimi K2.6 是一款开源的原生多模态智能体模型,在长程编码、编码驱动设计、主动自主执行以及群体任务编排等实用能力方面实现了显著提升。Python00
MiniMax-M2.7MiniMax-M2.7 是我们首个深度参与自身进化过程的模型。M2.7 具备构建复杂智能体应用框架的能力,能够借助智能体团队、复杂技能以及动态工具搜索,完成高度精细的生产力任务。Python00