dongxia2030 2014-06-16 04:58
浏览 47
已采纳

Alfresco ::很少有PHP API可用

I am trying to use alfresco. I want to use PHP restfull APIs.

Followings are my task.
1) Listing of all directory and documents.
2) Upload a file and create or add properties/metadata for the file.
3) Checkout and checkin a file.
4) Retrieve a specific version of a file. 
5) Create and edit tag. 

I got list of APIs from.

http://localhost:8080/alfresco/service/index/uri/
and 
http://wiki.alfresco.com/wiki/2.1_REST_API

Some of them is working and some of them is not working. Can anyone provide me the restfull PHP APIs for above tasks.

Even I am getting internal server error. Below is the code to add/create a tag.

<form       
action="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/b0697dd1-
ae94-4bf6-81c8-5e2fa098ddfa/tags" method="post">    
<input type="text" name="name" value='["t222a","t222b","t222c"]' />
<input type="text" name="tags" value='["t222a","t222b","t222c"]' />     
<input type="submit" />
</form>

Can anyone help me to figure it out?

Also there is no such help how I use custom data using API call.

Thanks in Advance

  • 写回答

1条回答 默认 最新

  • dpy83214 2014-06-16 09:34
    关注

    Your use case sounds like a typically usecase for CMIS. Take a look at the Apache Chemistry CMIS PHP Client

    If you want to use Alfresco's REST API Assuming that you're using Alfresco 4.2 then take a looks at the offical REST API docs.

    as most REST APIs most of Alfresco's Webscripts expects a json payload and not a FormData. The following curl is an example to add a tag (basis auth with admin/admin):

    curl "http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/4c3aa00e-2aee-440e-aab5-0bb0570d8b01/tags" -H "Content-Type: application/json" -H "Authorization: Basic YWRtaW46YWRtaW4=" --data-binary "[""tag1"", ""tag2""]"
    

    If you want to POST this via browser the you'll have to build the XHR-request on your own, e.g. by using jquery:

    <html>
    <body>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript">
            $.ajax({
                type: "POST",
                url: "http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/4c3aa00e-2aee-440e-aab5-0bb0570d8b01/tags",
                data: JSON.stringify(["tag3", "tag4"]),
                success: function() {},
                dataType: "json",
                contentType: "application/json"
            });
        </script>
    </body>
    

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值