dongmeng4742
2013-08-27 10:22 阅读 15
已采纳

以编程方式/自动生成box.com上传小部件

I have a project in which I want to generate upload widgets for different folders automatically (and by that I mean I want to generate them from my application, and not to go each time on Box.com website and manually click on the generate embeded widget code). Let me explain a bit: so, presume I have 1 account from which I want my users to interact with Box.com. I am working in a PHP environment, and I easily get my access token and my refresh token. I managed to comply a small library of cUrl requests for a simple file-handling process, but I recently saw that you can do it by widgets generated from box.com. The view/download widget is easy to generate for certain folders, but I'm having trouble with the upload widget. I need to access Box.com website and manually click some links to generate an uploading script.

Can I do it without manually clicking on links on the Box.com?

This is an example of generated upload widget from Box.com:

<script 
src="https://YOUR_BOX_APP.app.box.com/embed/upload.js?token=TOKEN_GENERATED_FOR_UPLOAD&folder_id=YOUR_FOLDER_ID&w=385&h=385&i=&d=1&t=YOUR_TITLE&r=1" 
type="text/javascript">
</script>

When I looked a bit inside that script, I saw that it uses the Box.com V1 uploading api, and not the V2 api.

As final questions: How can I generate that token from within the script to actually map onto my folder id element? Is there any default token that goes with any folder id I might use?

EDIT: I guess I found my answer here, though it's not for a long time: http://developers.box.net/w/page/35640290/APiFunction_toggle_folder_email

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    duanmu2013 duanmu2013 2013-08-27 19:59

    You can make the same request in V2:

    curl https://api.box.com/2.0/folders/FOLDER_ID \ -H "Authorization: Bearer ACCESS_TOKEN" \ -d '{"folder_upload_email": {"access": "open"}}' \ -X PUT

    点赞 评论 复制链接分享

相关推荐