ユーザーが自分のサイトに接続できるようにするために Gigya を使い始めたところです。すでにログイン システムを持っているので、既存のユーザーを Gigya サービスに接続したいだけです。
これを行うために、サイトから提供された UID を持つ Gigya User オブジェクトを返す「gigya.services.socialize.notifyLogin」関数を呼び出しました。[図 1] Cookie に追加するなど、この User オブジェクトを使用して何かを行う必要がありますか?それとも参照のためだけですか?
私が抱えている問題は別のページにあります。ユーザーがソーシャル メディア アカウントに接続できるようにしたいと考えています。「showAddConnectionsUI」関数を使用して API キーを渡しましたが、返されたオブジェクトには User オブジェクトが含まれていません。この関数からユーザー接続と重要な情報を取得するにはどうすればよいですか? API キーと一緒に追加情報を送信する必要がありますか? 【図2】
ウィキ、ドキュメント、フォーラムを読んでアドバイスを求めて数日過ごしましたが、まだ行き詰まっています。どんな助けでも大歓迎です。前もって感謝します、ベン
【図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>
役立つヘルプ、アドバイス、コードスニペットは大歓迎です