2010-12-02 3 views
1

私はちょうどユーザーが自分のサイトに接続できるようにGigyaを使用し始めました。私はすでにログインシステムを持っているので、既存のユーザーをGigyaサービスに接続したいだけです。Gigyaユーザーオブジェクトが見つかりません

これを行うには、自分のサイトから提供されたUIDを持つGigya Userオブジェクトを返す "gigya.services.socialize.notifyLogin"関数を呼び出しました。 [fig 1] このUserオブジェクトを使って何かをする必要がありますか?クッキーに追加するか、参照用です。

私は他のページにあるという問題は、ユーザーがソーシャルメディアアカウントに接続できるようにしたいのですが。 "showAddConnectionsUI"関数を使用してAPIキーを渡しますが、返されたオブジェクトにはUserオブジェクトがありません。どのようにしてこの機能からユーザーの概念と重要な情報を得るのですか?私は私のapiキーと共に追加の情報を送る必要がありますか? [図2]

私はwiki、ドキュメンテーション、フォーラムを読んで数日を過ごしましたが、まだ悩んでいます。どんな助けでも大歓迎です。事前のおかげで、ベン

[図1]

<script type="text/javascript" src="http://cdn.gigya.com/js/socialize.js?apiKey=<?php echo $key; ?>"></script> 
<script type="text/javascript"> 
    var gigyaConf = { APIKey: "<?php echo $key; ?>", signIDs: "true" } 

    var signature = "<?php echo $signature; ?>"; 
    var siteUID = "<?php echo $userId; ?>"; 
    var timestamp = "<?php echo $timestamp; ?>"; 

    var gigyaParams = 
    { 
     siteUID:siteUID, 
     timestamp:timestamp, 
     signature:signature, 
     callback:gigyaNotifyLoginCallback 
    }; 

    gigya.services.socialize.notifyLogin(gigyaConf, gigyaParams); 

    function gigyaNotifyLoginCallback(eventObj) { 
     if (eventObj.errorCode != 0) { 
      alert('Gigya Error: ' + eventObj.errorMessage); 
     } 
    } 
</script> 

[図2]

<script type="text/javascript" lang="javascript" src="http://cdn.gigya.com/JS/socialize.js?apikey=<?php echo $key; ?>"></script> 
<script> 
    var conf = { APIKey: '<?php echo $key; ?>', signIDs: 'true' }; 

    $(document).ready(function(){ 
     gigya.services.socialize.getUserInfo(conf, { callback: renderUI }); 

     gigya.services.socialize.addEventHandlers(conf, 
     { 
      onConnectionAdded: renderUI, 
      onConnectionRemoved: renderUI 
     }); 
    }); 
</script> 

<script> 
    function renderUI(res) { 
     if (res.user != null && res.user.isConnected) { 
      document.getElementById("name").innerHTML = res.user.nickname; 
      if (res.user.thumbnailURL.length > 0) 
       document.getElementById("photo").src = res.user.thumbnailURL; 
      else 
       document.getElementById("photo").src = "http://cdn.gigya.com/site/images/bsAPI/Placeholder.gif"; 
      document.getElementById("profile").style.display = "block"; 
     } else { 
      document.getElementById("profile").style.display = "none"; 
     } 
    } 
</script> 
<div id="content"> 
    <h5>Step 1: Connect</h5> 
    <div id="divConnect"></div> 
    <script type="text/javascript"> 
     gigya.services.socialize.showAddConnectionsUI(conf, { 
      height:65, 
      width:175, 
      showTermsLink:false, 
      hideGigyaLink:true, 
      useHTML:true, 
      containerID: "divConnect" 
     }); 
    </script> 
    <br /> 
    <h5>Step 2: See User Info</h5><br /> 
    <div id=profile style="display:none;"> 
     <img id="photo" src="" width="60" /> 
     <br /> 
     <span id="name" ></span> 
    </div> 
</div> 

すべてのヘルプ、アドバイス、役立つだろうコードsnippitsが大幅

答えて

3

再認識されるであろうあなたの最初の質問ですが、Gigya Userオブジェクトで特別なことをする必要はありません。あなたの参考のためです。

Re:あなたのコードは、あなたがJQueryを使用しているかどうかわかりませんが、$(document).ready関数でエラーが発生しました。私はbody onLoadを追加してコードを少し修正し、すべてが機能しました。これはプロバイダと接続していることを前提としています。ここに私のコードだ...それが役に立てば幸い:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<script type="text/javascript" lang="javascript" src="http://cdn.gigya.com/JS/socialize.js?apikey=<?php echo $key; ?>"></script> 
<script> 

    var conf = { APIKey: '<?php echo $key; ?>', signIDs: 'true' }; 

    function onLoad() { 

     gigya.services.socialize.getUserInfo(conf, { callback: renderUI }); 

     gigya.services.socialize.addEventHandlers(conf, 
     { 
      onConnectionAdded: renderUI, 
      onConnectionRemoved: renderUI 
     }); 
    } 

</script> 

<script> 
    function renderUI(res) { 

     if (res.user != null && res.user.isConnected) { 
      document.getElementById("name").innerHTML = res.user.nickname; 
      if (res.user.thumbnailURL.length > 0) 
       document.getElementById("photo").src = res.user.thumbnailURL; 
      else 
       document.getElementById("photo").src = "http://cdn.gigya.com/site/images/bsAPI/Placeholder.gif"; 
      document.getElementById("profile").style.display = "block"; 
     } else { 
      document.getElementById("profile").style.display = "none"; 
     } 
    } 
</script> 


<body onload="onLoad()"> 

<div id="content"> 
    <h5>Step 1: Connect</h5> 
    <div id="divConnect"></div> 
    <script type="text/javascript"> 
     gigya.services.socialize.showAddConnectionsUI(conf, { 
      height:65, 
      width:175, 
      showTermsLink:false, 
      hideGigyaLink:true, 
      useHTML:true, 
      containerID: "divConnect" 
     }); 
    </script> 
    <br /> 
    <h5>Step 2: See User Info</h5><br /> 
    <div id=profile style="display:none;"> 
     <img id="photo" src="" width="60" /> 
     <br /> 
     <span id="name" ></span> 
    </div> 
</div> 

</body> 
</html> 
+0

をあなたは私が正しく動作しているように見えるのonLoad機能のためのjQueryを使用していたように、ご返信いただきありがとうございます。この例では動作しますが、返された結果にUserオブジェクトは返されません。他のパラメータ{opperationとcontext}は期待通りに返されますが、ユーザオブジェクトはそこにありません。ローカルホスト上でのみテストするように、動作する前に、設定用のpannelに各ソーシャルメディアプロバイダの個別の設定をセットアップする必要がありますか? – bpneal

関連する問題