我想要检索文件和文件夹列表,下载,上传和删除文件.
我有一个microsoft开发者clientID和clientSecret.
任何人都可以开始使用OAuth连接到skyDrive并使用API吗?
非常感谢!
>看看SkyDrives REST API.
>您可以使用PHP cURL执行GET和POST.
>使用json_decode()
创建接收数据的映射.
>对于您发送的任何数据,使用PHP创建maps并使用json_encode()
将它们转换为JSON.
试试API
Here is an interactive API you can try out live to see the responses.
发出请求
Example(取自其他SO答案):
$url = 'POST https://apis.live.net/v5.0/me/skydrive/files'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POSTFIELDS,array('access_token' => TOKEN,'name' => 'file','filename' => "@HelloWorld.txt")); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); $result = curl_exec($ch); curl_close($ch);
请求类型:http://msdn.microsoft.com/en-us/library/live/hh243648.aspx#http_verbs
我还建议您查看curl_setopt()
,以便更好地了解如何使用cURL执行您需要的不同类型的请求. (Also this answer on SO has some good explanation on POST vs GET using cURL.)
To delete a file,make a DELETE request to /FILE_ID.
To create a new File resource,you can either make a POST request to /FOLDER_ID/files,a POST request to the /UPLOAD_LOCATION for the target folder,or a PUT request to /FOLDER_ID/files/.
>下载文件:
To get properties for a File resource,make a GET request to /FILE_ID (the target file ID).
>文件资源将包含从源字段中从SkyDrive下载文件的URL.
>检索文件列表:
To get the root Folder resource by using the Live Connect REST API,make a GET request to either /me/skydrive or /USER_ID/skydrive.
To get a subfolder resource,make a GET request to /FOLDER_ID.
>创建文件夹:
To create a new Folder resource,make a POST request to /FOLDER_ID. Pass the name and description attributes in the request body
To delete a folder,make a DELETE request to /FOLDER_ID.
不幸的是,我对OAuth的体验有限.我只能提供一些相关的链接和建议,希望对此有所帮助.
Review the Protocol Overview并考虑是否要自己实现某些内容,或使用库.快速谷歌搜索给了我:
> http://code.google.com/p/google-api-php-client/wiki/OAuth2
> http://code.google.com/p/oauth2-php/
> http://php.net/manual/en/book.oauth.php
其他一些可能有用的链接和指南: