diff options
author | Aaron Parecki <aaron@parecki.com> | 2014-12-25 18:50:34 -0800 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2014-12-25 18:50:34 -0800 |
commit | 430609b9005bb93ce2c6b21405cea0ede2b17a9d (patch) | |
tree | 090b64c2242ba5e8bbe8342a9a9494dcbeb1bf41 /views | |
parent | 2cd148c792a47fea18d760b723d23569ae52d390 (diff) |
adds instagram auth
Diffstat (limited to 'views')
-rw-r--r-- | views/settings.php | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/views/settings.php b/views/settings.php index 61feefc..9860a91 100644 --- a/views/settings.php +++ b/views/settings.php @@ -10,11 +10,8 @@ <h3>Twitter</h3> <input type="button" id="twitter-button" value="Checking" class="btn"> - - <!-- <h3>Instagram</h3> - - --> + <input type="button" id="instagram-button" value="Checking" class="btn"> </div> <script> @@ -60,6 +57,10 @@ function save_facebook_token(token) { } $(function(){ + $("#facebook-button").click(function(){ + FB.login(window.quillHandleFbLogin, {scope:'publish_actions'}); + }); + $.getJSON("/auth/twitter", function(data){ // Check if we're already authorized with twitter if(data && data.result == 'ok') { @@ -81,8 +82,26 @@ $(function(){ } }); - $("#facebook-button").click(function(){ - FB.login(window.quillHandleFbLogin, {scope:'publish_actions'}); + $.getJSON("/auth/instagram", function(data){ + // Check if we're already authorized with Instagram + if(data && data.result == 'ok') { + $("#instagram-button").val("Connected").addClass("btn-success"); + } else if(data && data.url) { + $("#instagram-button").val("Sign In").data("url", data.url).addClass("btn-warning"); + } else { + $("#instagram-button").val("Error").addClass("btn-danger"); + } + }); + + $("#instagram-button").click(function(){ + if($(this).data('url')) { + window.location = $(this).data('url'); + } else { + $.getJSON("/auth/instagram", {login: 1}, function(data){ + window.location = data.url; + }); + } }); + }); </script> |