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 StartedRust0153- DDeepSeek-V4-ProDeepSeek-V4-Pro(总参数 1.6 万亿,激活 49B)面向复杂推理和高级编程任务,在代码竞赛、数学推理、Agent 工作流等场景表现优异,性能接近国际前沿闭源模型。Python00
LongCat-Video-Avatar-1.5最新开源LongCat-Video-Avatar 1.5 版本,这是一款经过升级的开源框架,专注于音频驱动人物视频生成的极致实证优化与生产级就绪能力。该版本在 LongCat-Video 基础模型之上构建,可生成高度稳定的商用级虚拟人视频,支持音频-文本转视频(AT2V)、音频-文本-图像转视频(ATI2V)以及视频续播等原生任务,并能无缝兼容单流与多流音频输入。00
auto-devAutoDev 是一个 AI 驱动的辅助编程插件。AutoDev 支持一键生成测试、代码、提交信息等,还能够与您的需求管理系统(例如Jira、Trello、Github Issue 等)直接对接。 在IDE 中,您只需简单点击,AutoDev 会根据您的需求自动为您生成代码。Kotlin03
Intern-S2-PreviewIntern-S2-Preview,这是一款高效的350亿参数科学多模态基础模型。除了常规的参数与数据规模扩展外,Intern-S2-Preview探索了任务扩展:通过提升科学任务的难度、多样性与覆盖范围,进一步释放模型能力。Python00
skillhubopenJiuwen 生态的 Skill 托管与分发开源方案,支持自建与可选 ClawHub 兼容。Python0112