通过PHP中的Chemistry从Alfresco下载文件


Download file from Alfresco through Chemistry in PHP

我目前在通过Chemistry从Alfresco下载文件时遇到问题。

这是我的代码:

// Create the session
$repository = new CMISService($repositoryUrl, $userName, $password);
$uuid = $_GET['uuid'];
$contentData = $repository->getObject($uuid);
$tempurl = $repository->getLastRequestURL();
// TEMPORARY URL IS THIS: "http://193.43.168.90:8082/alfresco/api/-default-/public/cmis/versions/1.1/atom/id?id=6b82d8db-2003-467d-91e3-17a2d27f6a68";
$fp = fopen($tempurl, 'r');
$DMSContent = stream_get_contents($fp);
fclose($fp);

我无法下载该文件,因为它返回"HTTP请求失败!HTTP/1.1 401未经授权"。就好像我没有登录Alfresco一样。我该怎么做?

在Alfresco CMIS和Chemistry工作时,我也有过类似的经历,但还没有开始工作。以下是解决方案:

使用RESTapi下载servlet专门用于提取文件:

https://wiki.alfresco.com/wiki/URL_Addressability#DownloadContentServlet

你需要先拿到票:

/露天/服务/api/登录?u=用户名&pw=密码

它将在xml标记之间返回,您可以很容易地将其解析出来,并将其作为alf_ticket参数传递给下载servlet。

问候