Can i get link for widget? - box-api

my site is using box-api to show documents and folders. I created php script what generates new folders structure for projects. Now i want to generate link for every new project folder and embed it as widget to another page of the site. Is it possible?

Yes, you can generate the link for the embed widget. Follow the documentation here
Note that when you first generate one, you have to send in the right # of 0's into the URL. Then a random-number will be returned in that spot in the URL. It isn't generated programatically. It is a random number. It stores the param settings so the next time you load w/ that same random number, it doesn't need to pass all the params to maintain the same look and feel.

Related

Access publicly shared OneDrive folder via API

I have a publicly shared OneDrive folder with some various sub-folders and files. I.e. I have shared it via a link, so anyone with this link can access them.
Is there a way I can access these files from either client-side JavaScript or some server-side code via a REST API of some sort? Without having to use any sort of user-specific credentials?
What I've been trying
I've been looking at the Accessing Shared Content page, and it looks like what I want, but can't figure out how to use it.
I've taken something that looks like an id from the shared URL, which looks to be a long hexadecimal number (which seems to be an id pointing at me?), an !, and then a number (which I assume has to do with the shared resource).
I've then tried to stick it in this URL:
https://api.onedrive.com/v1.0/shares/<id>/root?expand=children
But I get back a 400 Bad Request, so something isn't quite right...
I'm thinking maybe some sort of authentication is missing, but since the shared files are public, I don't users to have to login with their credentials, and can't of course use my own in code.
I've tried to register an app, where I get an application id (guid) and can generate Passwords and Key-Pairs. Was hoping maybe I could use that, but don't see in the API how and where to actually use those...
Goal
The shared folder contains sheet music for a choir, that I'm responsible for keeping updated (and OneDrive syncing is super handy here).
Some members aren't very computer savvy, so I'd like to make seeing and downloading these files as easy as possible. The shared link with a "go here to this other strange site and find the files there"-text sort of works, but I would much rather like to list the files directly in a member-only area of our website. Basically just "here are the files, click on one to download it".
Yes, you can use the REST API to access the contents of a folder.
The API is the one you mentioned, the shares API. However, it sounds like you are perhaps using the wrong ID.
The most straightforward way to do this is to follow the instructions to encode the actual sharing URL into a token. This way you create a base64 encoded version of the sharing link, append a "u!" to the front of that string, and then make the exact call you already mentioned. You'll get back a list of the files in the shared folder and you can go from there.
Here's an example of this:
Here's a sharing link to a folder in OneDrive with some photos in it.
https://1drv.ms/f/s!AtuAM_NacwVahiFpuMGS_BiQCwWu
To convert this URL into the API, you first base64 encode the URL and append u!
u!aHR0cHM6Ly8xZHJ2Lm1zL2YvcyFBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1
Now you can use this URL as the sharing token, and expand children and thumbnails:
https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL2YvcyFBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1/root?expand=children
Clicking on this bottom link should give you the JSON response, which includes the shared folder and the children inside the folder.

Google drive integration

We are building a web application that should get all files from a specific folder in our Drive (read only). The problem is that I can't find a way to access our files without using OAuth. Basically I would want to request our files using AJAX and present the contents of them on a page (without the user having to do anything). Is this at all possible and have I missed something?
Whenever I try something without using OAuth I get a global internalError (being related to authorization according to the current documentation).
The experience I'm trying to achieve:
User enters http://domain.com/posts > Get all public files from folder Y > Sort them by date > Show the titles in HTML > User clicks title > User is presented with full contents of the file as HTML.
Is this possible?
Thanks in advance! :)
UPDATE: To clarify: I would want to depend on our API key only.

Google Drive API without Ouath and receive files

We are building a web application that should get all files from a specific folder in our Drive (read only). The problem is that I can't find a way to access our files without using OAuth. Basically I would want to request our files using AJAX and present the contents of them on a page (without the user having to do anything). Is this at all possible and have I missed something?
Whenever I try something without using OAuth I get a global internalError (being related to authorization according to the current documentation).
The experience I'm trying to achieve:
User enters http://domain.com/posts > Get all public files from folder Y > Sort them by date > Show the titles in HTML > User clicks title > User is presented with full contents of the file as HTML.
Is this possible?
Thanks in advance! :)
UPDATE:
To clarify: I would want to depend on our API key only.
You can do it this way, without using Google Drive API:
Make the folder public
Copy the folder ID from the URL
Append it to https://googledrive.com/host/ e.g. https://googledrive.com/host/0BzEbtMoF6IXbaVN2Qmx1em9qS0k/
You will get a directory index with all files listed and if the (sub)folder contains an index.html file, it will be rendered instead.
To get the JSON or XML file list, use YQL.

Box.net URL Schemes

I'm writing an iPhone app, MyApp, which needs access to documents on and off-line. My users are already managing these documents (pdf's, movies, etc) via the Box iPhone app synching with the company server.
If MyApp knows the path & filename of a document, is it possible to use the Box URL Schemes to launch Box and open the document externally?
MyApp doesn't need to store or access the files and since Box already has the files downloaded, there's no point storing them in the Document space of both apps.
If there is such a URL Scheme, two follow up questions are: A) is there a callback to return to MyApp when the document is closed, and B) can MyApp use another URL Scheme to get a list of documents?
NSURL *ourURL = [NSURL URLWithString:#"box://some/path/to/fileid?callback=myapp://"];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
If this isn't currently possible, but of interest to Box, I'm interested in being a beta tester/early adopter.
If you just want to direct the user to a Box page, you may be able to direct the user to a specific file in one of two ways:
1) If the file is shared in Box and you have the shared name, you can generate a shared url (see sharing in the docs at developers.box.com). This only works for files that were shared, however.
2) If you have the file id of the file in Box, you can generate a URL to which the user can login to one's Box account and view the content. You can determine that URL by going into Box and seeing how URLs are displayed when you click on a particular file. We don't like to advertise that URL for developers, however, because we don't guarantee that this URL format will be maintained in the future. It hasn't changed in a while, so it's probably safe to use, but Box provides that "use it at your own risk" disclaimer.
Unfortunately, Box doesn't have a way to pull up a file based on file path. You need the file id or shared name. There isn't a url that relies on file or folder names.

How to save a local file programmatically given an amount of data and a file name with html5

I want to implement this use case found on the W3C File API document:
User agents should provide the ability to save a local file programmatically given an amount of data and a file name.
Example: A Spreadsheet App. User interacts with a form, and generates some input. The form then generates a CSV (Comma Separated Variables) output for the user to import into a spreadsheet, and uses "Save...". The generated output can also be directly integrated into a web-based spreadsheet, and uploaded asynchronously.
Source: http://www.w3.org/TR/file-upload/#requirements
From my understanding, it should be possible to create a completely offline Spreadsheet app with this, but I could not find a single example both in the W3C document or on the web that has this kind of use case implemented. At least not a completely offline one. Of course it doesn't need to be a spreadsheet application; a simple text editor or TODO manager would suffice. Am I missing something?
Also, would this make it possible to create one of the previously mentioned applications (text editor, todo manager or even spreadsheet app) from a single html5 file (with embedded JS and css)?
I seems I didn't search hard enough, here's an example of what I want http://html5-demos.appspot.com/static/a.download.html