2011-12-15 30 views
1

我在我的系統中開發了Live ID OAuth的代碼。我想改變Windows Live ID提供的圖像。如何更改OAuth windows live ID登錄按鈕的圖像?

我該如何改變它。

當我登錄一次後,它會自動提醒登錄細節,當我再次加載頁面。 (F5)在我點擊按鈕之前。

是什麼原因?

我的代碼是.........

<div> 
<script src="//js.live.net/v5.0/wl.js" type="text/javascript"></script> 
<script type="text/javascript"> 

    var APPLICATION_CLIENT_ID = "myclientId", 
    REDIRECT_URL = "myredirectURl"; 
    //WL.Event.subscribe("auth.login", onLogin); 
    WL.init({ 
     client_id: APPLICATION_CLIENT_ID, 
     redirect_uri: REDIRECT_URL, 
     response_type: "token" 
    }); 
    var scopesArr = ["wl.signin", "wl.postal_addresses", "wl.phone_numbers", "wl.emails"]; 
    WL.ui(
    { 
     name: "signin", 
     element: "signInButton", 
     scope: scopesArr 
    }); 



    function userContactInfo(sesion) { 
     var postalAddresses, phoneNumbers, emailAddresses; 
     WL.api(
    { 
     path: "me", 
     method: "GET" 
    }, 

    function (response) { 
     if (!response.error) { 
      alert('hello name:' + response.first_name); 
      alert('hello email:' + response.emails['preferred']); 
      $.ajax({ 
       type: "POST", 
       url: "Login.aspx/SaveFacebookAutoSignUp", 
       data: "{ 'Name':'" + name + "', 'EmailId':'" + email + "'}", 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: function (data) { 
        alert("You have successfully sign in.Please Wait, we redirect you in a second."); 
        alert(data); 

       } 

      }); 
     } 
    }); 
    } 


    function onLogin() { 
     var session = WL.getSession(); 
     if (session) { 
      userContactInfo(session); 
     } 
    } 

    function onLogin1() { 
     WL.Event.subscribe("auth.login", onLogin); 
     var session = WL.getSession(); 
     if (session) { 
      userContactInfo(session); 

     } 
    } 

</script> 
<div id="signInButton"> 
</div> 

回答

0

下面是我用電話與一個按鈕SIGIN代碼後,你可以添加你想要的圖像,希望對您有所幫助:

<body> 
    <input id="login" type="image" src="Images/Image.png" onclick="login();"/> 
</body> 

<script type="text/javascript"> 

     var APPLICATION_CLIENT_ID = "xxxx", 
     REDIRECT_URL = "xxxx"; 

     WL.Event.subscribe('auth.sessionChange', function (e) { 
      document.getElementById('login').innerHTML = (e.status === "connected" ? "Sign out" : "Connect"); 
     }); 
     WL.init({ 
      client_id: APPLICATION_CLIENT_ID, 
      redirect_uri: REDIRECT_URL 
     }); 

     function login() { 
      if (WL.getSession() === null) 
       WL.login({ scope: "wl.signin" }); 
      else 
       WL.logout(); 
     } 

    </script>