Last active
August 29, 2015 14:17
-
-
Save jz5/6e960486050850c7e00d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// (省略) | |
function onAuthenticated(token, authWindow) { | |
if (token) { | |
if (authWindow) { | |
removeLoginButton(); | |
authWindow.close(); | |
} | |
(function ($) { | |
// Upload an item to OneDrive from a URL | |
$.ajax({ | |
url: 'https://api.onedrive.com/v1.0/drive/special/photos/children?access_token=' + token, | |
type: 'POST', | |
headers: { | |
'Prefer': 'respond-async', | |
'Content-Type': 'application/json' | |
}, | |
dataType: 'json', | |
data: '{' + | |
'"@content.sourceUrl": "http://pronama.azurewebsites.net/wp-content/uploads/2015/02/20150206.jpg",' + | |
'"name": "20150206.jpg",' + | |
'"file": { }' + | |
'}', | |
}).done(function () { | |
// MEMO: unreachable (2015/3/14) | |
console.log("success"); | |
}).fail(function (xhr, textStatus, errorThrown) { | |
console.log(xhr); | |
}); | |
})(jQuery); | |
} | |
else { | |
alert("Error signing in"); | |
} | |
} | |
// start the whole thing off by calling odauth() in non-click mode. | |
// if the user isn't logged in already, a sign-in link will appear | |
// for them to click. | |
odauth(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment