4
Contributors
6
Replies
11
Views
4 Years
Discussion Span
Last Post by pritaeas
1

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...

Edited by veedeoo: info added

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.