We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,055 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Access SkyDrive Using PHP

Hello Community,
I was wondering if there is a way to access SkyDrive using php i have looked at so many forums and i could not find anything and what i did find was too complicated to understand, what i want is a way to create files or folders, get files and delete files or folders.

4
Contributors
6
Replies
2 Days
Discussion Span
3 Months Ago
Last Updated
7
Views
joshl_1995
Junior Poster
150 posts since Jul 2012
Reputation Points: 3
Solved Threads: 2
Skill Endorsements: 1
diafol
Keep Smiling
Moderator
10,653 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57

I went to that but i don't know how to use it.

joshl_1995
Junior Poster
150 posts since Jul 2012
Reputation Points: 3
Solved Threads: 2
Skill Endorsements: 1

I went to that but i don't know how to use it.

There's a live SDK: http://isdk.dev.live.com/ISDK.aspx

Don't know what more to suggest. There's even a video: http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-134C

Learning and experimenting with new API takes time and effort. It'll take you a good few hours, if not more.

diafol
Keep Smiling
Moderator
10,653 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57

In addition to what Diafol already mentioned, you can use plain javascript for OR use the REST. You will need to read more on how to implement the REST in this API, then and ONLY then you can convert the REST codes to PHP using the cURL plugins.

Yes, it will take you some time, but the learning experience is priceless.

To use the REST API, you can read more about it here.

basic syntax for the REST connection

 https://apis.live.net/v5.0/me/albums?access_token=ACCESS_TOKEN 

basic REST syntax for the skydrive as suggested by the microsoft

    POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN 

Basic information for POST and GET for cURL are shown here.

basic implementation of POST using cURL to the skydrive api,, just like the apis.live...albums

$url = 'POST https://apis.live.net/v5.0/me/skydrive/files';
$form_data = array(
              'token'=> 'ACCESS_TOKEN',
              'file' => 'FILE_NAME',
              'name' => 'NAME_OF_DIRECTORY'
              )

send the data to the API using the cURL "CURLOPT_POSTFIELDS "

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $form_data);
$result = curl_exec($ch);
curl_close($ch);

the rest are just a matter of retrieving the data response from the remote server..

I am not sure if the skydrive response is json encoded array. If it is, then you can probably get away with it by passing the cURL output ( response from the remote server)...use something like this to test the response from the skydrive.

use var_dump to view the response array from the remote server..

    var_dump(json_decode($result));

That's pretty much it... the rest is all up to you to experiment...

veedeoo
Master Poster
735 posts since Oct 2011
Reputation Points: 298
Solved Threads: 130
Skill Endorsements: 13

Can i just ask, what is that code supposed to do because the only response i'm getting is "NULL".

This is what i'm trying:

<?php
    $url = 'POST https://apis.live.net/v5.0/me/skydrive/files';
    $form_data = array(
        'token'=> 'ACCESS_TOKEN',
        'file' => 'Test',
        'name' => 'me'
    );

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $form_data);
    $result = curl_exec($ch);
    var_dump(json_decode($result));
    curl_close($ch);
?>

Also i don't know where to get the access token.

joshl_1995
Junior Poster
150 posts since Jul 2012
Reputation Points: 3
Solved Threads: 2
Skill Endorsements: 1

You get an access token, after the user has logged in. Read more here, or read more about the OAuth flow here.

pritaeas
Posting Prodigy
Moderator
9,287 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,458
Skill Endorsements: 86

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0713 seconds using 2.68MB