Was this article helpful?

Update Status

Last modified 11:53, 15 Sep 2014

See it in Action

 

Read More

API Reference

Check Out the Code

<html>
<head>
    <title>Gigya Demo  - update status</title>
    <style>
	 body {font-family:Arial;font-size: 12px; background-color:#fff; line-height:20px;margin:1px;}
	 h5 { font-size: 12px; color: #6e6e6e; padding: 0px; margin: 0px; }
     h6 { font-size: 14px; color: #6e6e6e; padding: 0px; margin: 0px; font-weight:bold; }
	</style>
	<SCRIPT type="text/javascript" lang="javascript" 
	   src="http://cdn.gigya.com/JS/socialize.js?apikey=2_Y82PzwJ_chSFImHXaIDJClnLyJzmk-VFOavSsaNTzl6m901s_NNxRAS0xJ3bd3_N">
	   {
			cid: "Status Example page"
			,enabledProviders:  "facebook, twitter, yahoo, messenger, google, linkedin"
	   }
	   </SCRIPT>
	<script>
        
        
        function onLoad()
        {
            // get user info
            gigya.socialize.getUserInfo({callback:renderUI});	    
            
            // register for connect status changes
            gigya.socialize.addEventHandlers({ onConnectionAdded: renderUI, onConnectionRemoved: renderUI }); 
            
        }
    </script>
    

	<script type="text/javascript">

		function renderUI(res)
		{
		    document.getElementById('btnUpdateStatus').disabled = (res.user==null || !res.user.isConnected);
		}
		
		// Update the user's status
		function setStatus()
		{
			var params = 
			{
			    status: "This is a Status update test with a link. "
					+ "Check out 'Home' movie, here is the link: http://bit.ly/aCVmg",
			    callback:setStatus_callback
			};
			
			gigya.socialize.setStatus(params);
		}

		// Display a status message according to the response from reportAction.
		function setStatus_callback(response)
		{
			switch (response.errorCode )
			{
				case 0:
					document.getElementById('status').style.color = "green";
					document.getElementById('status').innerHTML = "Status Updated.";
					break;
				default:
					document.getElementById('status').style.color = "red";
					document.getElementById('status').innerHTML = "Unable to update status. response=" 
					+ response.errorCode + "; " + response.errorMessage;
			}
		}
    </script>

</head>
<body onload="onLoad()">
	<h5 >Step 1: Connect</h5>
	    <div id="divConnect"></div>
    <script type="text/javascript">
	    // show 'Add Connections' Plugin in "divConnect"
	    gigya.socialize.showAddConnectionsUI({ 
			height:65
			,width:175
			,showTermsLink:false // remove 'Terms' link
			,hideGigyaLink:true // remove 'Gigya' link
			,containerID: "divConnect" // The component will embed itself inside the divConnect Div 
		});
    </script>    
    <br />
    <h5>Step 2: Update Status</h5>
    <div >
    <span style="color:#6e6e6e" >Click the button below to update your status</span>
    </div>
    <input type=button id="btnUpdateStatus" onclick="javascript:setStatus()" value="post" />
    <div id="status"></div>
</body>
</html>

Note:
In order to make this code work in your environment, please:
  • Click the "view source" icon (link located above code on the right hand side) - This will open a popup window with a text version of the code, which you may copy.
  • The API key in the sample will only work on http://localhost/...
  • To load the page from your domain, modify the value of the "APIKey" field in the code to your own Gigya API Key. A Gigya API Key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API Key.

Was this article helpful?
Page statistics
74 view(s) and 1 edit(s)
Social share
Share this page?

Tags

This page has no custom tags.

Comments

You must to post a comment.

Attachments