Page History

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HTML
<div id="runningCodeExample" style="border: 1px solid skyblue; padding: 15px; width: 400px; display: block; height: auto;">
	<script>
        function onLoad()
        {
            // get user info
            gigya.socialize.getUserInfo({callback:renderUI});	    
            
            // register for connect status changes
            gigya.socialize.addEventHandlers({ onConnectionAdded: renderUI, onConnectionRemoved: renderUI }); 
            
        }
		function renderUI(res)
		{
		    document.getElementById('btnPublishAction').disabled = 
					(res.user == null || !res.user.isConnected);		    
		}
		// Create and Publish User's Action
		// This method is associated with the "btnPublishAction" click
		function publishAction() {
		    // Constructing a UserAction Object
		    var act = new gigya.socialize.UserAction();
			var ts = Date.now();
			// Setting the Title and subtitle
            act.setTitle("This is my title");
            act.setSubtitle("This is my subtitle");
            // Setting Link Back
            act.setLinkBack("https://demogigyademo.gigya.com");
			act.setUserMessage("This is my message to you @ " + ts);
		    // Parameters for the publishUserAction method, 
			// including the UserAction object
			var params = 
			{
			    userAction:act,
			    callback:publishAction_callback
			};
			
            // Publish the User Action
			gigya.socialize.publishUserAction(params);
		}
		// Display a status message according to the response from publishUserAction.
		function publishAction_callback(response)
		{
			switch (response.errorCode )
			{
				case 0:
					document.getElementById('status').style.color = "green";
					document.getElementById('status').innerHTML = "Newsfeed item sent.";
					break;
				default:
					document.getElementById('status').style.color = "red";
					document.getElementById('status').innerHTML = 
							"Unable to send newsfeed item. Error Code:" 
					        + response.errorCode + "; " + response.errorMessage;
			}
		}
		onLoad();
    </script>
	<b>Step 1: Connect</b>
	<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
                , disabledProviders: "yahoo" //Yahoo does not support sharing
				, containerID: "divConnect" // The component will embed itself inside the divConnect Div 
			});
        </script>    
    <br />
    <br />
    <b>Step 2: Post Newsfeed item</b><br />
    Click the button below to post a Newsfeed item<br />
    <input type=button id="btnPublishAction" onclick="javascript:publishAction()" value="Post" />
    <div id="status"></div>
</div>

...