Retrieves a RedCritter team profile.
This version of the GetTeamProfile command is used to retrieve the team profile based on the SecretKey and TeamName.
https://redcritterconnecter.com/services/gamificationv1/GetTeamProfile?SecretKey={SecretKey}&TeamName={TeamName}
SecretKey | string | yes | This SecretKey is an App or App Domain Secret Key. If an App Secret Key is specified, your default App Domain will be assumed. If an App Domain Secret Key is specified, that App Domain will be used. |
TeamName | string | yes | The TeamName parameter represents the name of the RedCritter team profile that you want to retrieve. The following characters cannot be used : | = [ ] , ; |
Code Samples Javascript, C#
GetTeamProfile with JavaScript
This is a minimal example of calling the GetTeamProfile API via HTML and Javascript. Remember to never use your Secret Keys on the client side.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<style type='text/css'>
body {
font-family: "Arial";
}
.rctable{
padding-top:20px;
padding-bottom:10px;
border-bottom:solid 1px #ccc;
width:600px;
}
.rclabel {
font-size:14px;
font-weight:bold;
}
.rcval{
font-size:14px;
padding-left:10px;
}
</style>
<script type="text/javascript">
var connecterURL = "https://www.redcritterconnecter.com/";
function getTeamProfile(secretKey, teamName, cbSuccess, cbFail) {
$.getJSON(connecterURL + "services/gamificationv1/getTeamProfile?jsoncallback=?", { secretKey: secretKey, teamName: teamName },
function (data) {
if (data.Result) {
cbSuccess(data);
} else {
cbFail(data);
}
});
}
//My Success Callback
function onMygetTeamProfileSuccessHandler(data) {
//data is JSON response
renderItems(data)
}
//My Failure Callback
function onMygetTeamProfileFailHandler(data) {
//Something went wrong
alert("Something went wrong");
}
//Sample function to generate the list output in html
function renderItems(data) {
var h = "";
var h = "<table class='rctable'>";
h += "<tr><td class='rclabel'>Team Name : </td><td class='rcval'>" + HTMLEncode(data.TeamName) + "</td></tr>"
h += "<tr><td class='rclabel'>Team ID: </td><td class='rcval'>" + HTMLEncode(data.TeamID) + "</td></tr>"
h += "</table>";
$("#results").html(h);
//display the results
$("#results").html(h);
}
function HTMLEncode(str) {
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
</script>
</head>
<body>
<table>
<tr>
<td>Secret Key</td>
<td>
<input type="text" id="tSecretKey" style="width: 500px" />
</td>
</tr>
<tr>
<td>Team Name</td>
<td>
<input type="text" id="tTeamName" style="width: 500px" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" onclick="getTeamProfile($('#tSecretKey').val(), $('#tTeamName').val(), onMygetTeamProfileSuccessHandler, onMygetTeamProfileFailHandler)" value="Get Team Profile" /></td>
</tr>
</table>
<br />
<div id="results"></div>
</body>
</html>
GetTeamProfile with C#
This is a minmal example of calling the GetTeamProfile API and parsing the JSON result into a populated C# object. This example uses asynchronous techniques to raise a callback when the response is received.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web; //Add reference to System.Web
using System.Runtime.Serialization.Json; //Add reference to System.Runtime.Serialization
namespace RedCritterConnecter.Samples
{
//Create a class to contain the response
public class GetTeamProfileResponse
{
public String TeamID { get; set; }
public String TeamName { get; set; }
public Boolean Result { get; set; }
}
public class GetTeamProfile
{
public delegate void OnGetTeamProfileResponse(GetTeamProfileResponse GetTeamProfileResponse);
public event OnGetTeamProfileResponse onGetTeamProfileResponse;
public delegate void OnGetTeamProfileResponseError(GetTeamProfileResponse GetTeamProfileResponse);
public event OnGetTeamProfileResponseError onGetTeamProfileResponseError;
const string CONST_ConnecterBaseURL = "https://www.redcritterconnecter.com/";
public void Execute(String SecretKey, String TeamName)
{
try
{
//Create url encoded parameters in query string
String queryString = "secretkey=" + System.Web.HttpUtility.UrlEncode(SecretKey) + "&teamname=" + System.Web.HttpUtility.UrlEncode(TeamName);
//Create a new instance of a WebClient
WebClient wc = new System.Net.WebClient();
//Prevent this request from caching in order to ensure that it is sent to server
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
//Attach an event handler to receive the response
wc.DownloadStringCompleted += onGetTeamProfileResponseReceived;
//Make the call
wc.DownloadStringAsync(new Uri(CONST_ConnecterBaseURL + "services/gamificationv1/GetTeamProfile?" + queryString, UriKind.Absolute));
}
catch
{
//Something went wrong communicating with the server
if (onGetTeamProfileResponseError != null)
{
onGetTeamProfileResponseError(null);
}
}
}
private void onGetTeamProfileResponseReceived(object sender, DownloadStringCompletedEventArgs e)
{
try
{
//Create a JSON serializer
System.Runtime.Serialization.Json.DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(GetTeamProfileResponse));
//Copy the string into a memory stream
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
//Read the stream into an object matching the response's type
GetTeamProfileResponse GetTeamProfileResponse = (GetTeamProfileResponse)s.ReadObject(ms);
//Work with the populated response object
if (GetTeamProfileResponse.Result == true)
{
//Request was accepted, raise the success event
onGetTeamProfileResponse(GetTeamProfileResponse);
}
else
{
//Something went wrong
if (onGetTeamProfileResponseError != null)
{
//Request failed, raise the error event
onGetTeamProfileResponseError(GetTeamProfileResponse);
}
}
}
catch
{
//Something went wrong
onGetTeamProfileResponseError(null);
}
}
}
}
Responses JSON, XML
XML Response
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="Connecter">
<Apps>
<App>
<AppDomains>
<AppDomain>
<AppDomainID>59</AppDomainID>
<Badges>
<Badge>
<BadgeID>103</BadgeID>
<BadgeName>Test</BadgeName>
<Count>1</Count>
<Description>Test Badge that doesn't require an action trigger</Description>
<ExpirationDate>2000-01-01 00:00:00.0000000</ExpirationDate>
<Expires>false</Expires>
<IconURL>
https://connecterstoredev.blob.core.windows.net/badges/badgeicon_0_{s|m|l}.png
</IconURL>
<Modified>2013-08-21T18:15:46.7488698Z</Modified>
<Unlocked>true</Unlocked>
<UserDeleted>false</UserDeleted>
<UserDisabled>false</UserDisabled>
</Badge>
</Badges>
<Certs />
<ExternalAccountID>(Default)</ExternalAccountID>
<IsPersonal>false</IsPersonal>
<RewardPoints>0</RewardPoints>
<Skills />
<TeamLeaderboards />
<UserLeaderboards />
<ValidatedDomain />
<ValidatedOrg />
</AppDomain>
</AppDomains>
<AppID>40</AppID>
<AppName>Office Heroes</AppName>
<Description>
Do you have what it takes to be the hero of the office ????
</Description>
<IconURL>
https://connecterstoredev.blob.core.windows.net/apps/appicon_40_{s|m|l}.png
</IconURL>
<ValidatedDomain />
<ValidatedOrg />
</App>
</Apps>
<PublicKey />
<Result>true</Result>
<ResultMessage />
<ResultTitle />
<RootImageURL>http://connecterstoredev.blob.core.windows.net/</RootImageURL>
<Settings />
<TeamID>2013-08-21 18:15:38.8567921</TeamID>
<TeamName>TestTeam</TeamName>
</Response>
JSON Response
{
"RootImageURL": "http://connecterstoredev.blob.core.windows.net/",
"TeamID": "2013-08-21 18:15:38.8567921",
"TeamName": "TestTeam",
"PublicKey": "",
"Apps": [
{
"AppID": 40,
"AppName": "Office Heroes",
"Description": "Do you have what it takes to be the hero of the office ????",
"IconURL": "https://connecterstoredev.blob.core.windows.net/apps/appicon_40_{s|m|l}.png",
"ValidatedDomain": "",
"ValidatedOrg": "",
"AppDomains": [
{
"AppDomainID": 59,
"ExternalAccountID": "(Default)",
"ValidatedDomain": "",
"ValidatedOrg": "",
"IsPersonal": false,
"Badges": [
{
"BadgeID": 103,
"BadgeName": "Test",
"Description": "Test Badge that doesn't require an action trigger",
"Count": 1,
"IconURL": "https://connecterstoredev.blob.core.windows.net/badges/badgeicon_0_{s|m|l}.png",
"Expires": false,
"ExpirationDate": "2000-01-01 00:00:00.0000000",
"Modified": "2013-08-21T18:15:46.7488698Z",
"Unlocked": true,
"UserDisabled": false,
"UserDeleted": false
}
],
"Certs": [],
"Skills": [],
"UserLeaderboards": [],
"TeamLeaderboards": [],
"RewardPoints": 0
}
]
}
],
"Settings": [],
"Result": true,
"ResultTitle": "",
"ResultMessage": ""
}
This version of the GetTeamProfile command is used to retrieve the team profile based on the SecretKey and TeamName and ExternalID. The Secret Key must be the App Secret Key.
https://redcritterconnecter.com/services/gamificationv1/GetTeamProfile?SecretKey={SecretKey}&ExternalAccountID={ExternalAccountID}&TeamName={TeamName}
SecretKey | string | yes | This SecretKey is an App Secret Key.The App Domain is determined by the External Account ID you provide. |
ExternalAccountID | string | yes | A unique ID for an App Domain that you create and manage. For example an App could have 2 App Domains managed separately by specifying an ExternalAccountID of 'Sales Dept' or 'IT Dept'. When passed as a parameter if the External Account ID does not exist. RedCritter Connecter will create a new App Domain on the fly with the ID that you specify. |
TeamName | string | yes | The TeamName parameter represents the name of the RedCritter team profile that you want to retrieve. The following characters cannot be used : | = [ ] , ; |
Code Samples Javascript, C#
GetTeamProfile with JavaScript
This is a minimal example of calling the GetTeamProfile API via HTML and Javascript. Remember to never use your Secret Keys on the client side.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<style type='text/css'>
body {
font-family: "Arial";
}
.rctable{
padding-top:20px;
padding-bottom:10px;
border-bottom:solid 1px #ccc;
width:600px;
}
.rclabel {
font-size:14px;
font-weight:bold;
}
.rcval{
font-size:14px;
padding-left:10px;
}
</style>
<script type="text/javascript">
var connecterURL = "https://www.redcritterconnecter.com/";
function getTeamProfile(secretKey, externalAccountID, teamName, cbSuccess, cbFail) {
alert(secretKey);
alert(externalAccountID);
alert(teamName);
$.getJSON(connecterURL + "services/gamificationv1/getTeamProfile?jsoncallback=?", { secretKey: secretKey,externalAccountID:externalAccountID, teamName: teamName},
function (data) {
if (data.Result) {
cbSuccess(data);
} else {
cbFail(data);
}
});
}
//My Success Callback
function onMygetTeamProfileSuccessHandler(data) {
//data is JSON response
renderItems(data)
}
//My Failure Callback
function onMygetTeamProfileFailHandler(data) {
//Something went wrong
alert("Something went wrong");
}
//Sample function to generate the list output in html
function renderItems(data) {
var h = "";
var h = "<table class='rctable'>";
h += "<tr><td class='rclabel'>Team Name : </td><td class='rcval'>" + HTMLEncode(data.TeamName) + "</td></tr>"
h += "<tr><td class='rclabel'>Team ID: </td><td class='rcval'>" + HTMLEncode(data.TeamID) + "</td></tr>"
h += "</table>";
$("#results").html(h);
//display the results
$("#results").html(h);
}
function HTMLEncode(str) {
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
</script>
</head>
<body>
<table>
<tr>
<td>Secret Key</td>
<td>
<input type="text" id="tSecretKey" style="width: 500px" />
</td>
</tr>
<tr>
<td>External Account ID</td>
<td>
<input type="text" id="tExternalAccountID" style="width: 500px" />
</td>
</tr>
<tr>
<td>Team Name</td>
<td>
<input type="text" id="tTeamName" style="width: 500px" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" onclick="getTeamProfile($('#tSecretKey').val(),$('#tExternalAccountID').val(), $('#tTeamName').val(), onMygetTeamProfileSuccessHandler, onMygetTeamProfileFailHandler)"
value="Get Team Profile" /></td>
</tr>
</table>
<br />
<div id="results"></div>
</body>
</html>
GetTeamProfile with C#
This is a minmal example of calling the GetTeamProfile API and parsing the JSON result into a populated C# object. This example uses asynchronous techniques to raise a callback when the response is received.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web; //Add reference to System.Web
using System.Runtime.Serialization.Json; //Add reference to System.Runtime.Serialization
namespace RedCritterConnecter.Samples
{
//Create a class to contain the response
public class GetTeamProfileResponse
{
public String TeamID { get; set; }
public String TeamName { get; set; }
public Boolean Result { get; set; }
}
public class GetTeamProfile
{
public delegate void OnGetTeamProfileResponse(GetTeamProfileResponse GetTeamProfileResponse);
public event OnGetTeamProfileResponse onGetTeamProfileResponse;
public delegate void OnGetTeamProfileResponseError(GetTeamProfileResponse GetTeamProfileResponse);
public event OnGetTeamProfileResponseError onGetTeamProfileResponseError;
const string CONST_ConnecterBaseURL = "https://www.redcritterconnecter.com/";
public void Execute(String SecretKey,String ExternalAccountID, String TeamName)
{
try
{
//Create url encoded parameters in query string
String queryString = "secretkey=" + System.Web.HttpUtility.UrlEncode(SecretKey) + "&externalaccountid=" + System.Web.HttpUtility.UrlEncode(ExternalAccountID) + "&teamname=" + System.Web.HttpUtility.UrlEncode(TeamName);
//Create a new instance of a WebClient
WebClient wc = new System.Net.WebClient();
//Prevent this request from caching in order to ensure that it is sent to server
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
//Attach an event handler to receive the response
wc.DownloadStringCompleted += onGetTeamProfileResponseReceived;
//Make the call
wc.DownloadStringAsync(new Uri(CONST_ConnecterBaseURL + "services/gamificationv1/GetTeamProfile?" + queryString, UriKind.Absolute));
}
catch
{
//Something went wrong communicating with the server
if (onGetTeamProfileResponseError != null)
{
onGetTeamProfileResponseError(null);
}
}
}
private void onGetTeamProfileResponseReceived(object sender, DownloadStringCompletedEventArgs e)
{
try
{
//Create a JSON serializer
System.Runtime.Serialization.Json.DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(GetTeamProfileResponse));
//Copy the string into a memory stream
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
//Read the stream into an object matching the response's type
GetTeamProfileResponse GetTeamProfileResponse = (GetTeamProfileResponse)s.ReadObject(ms);
//Work with the populated response object
if (GetTeamProfileResponse.Result == true)
{
//Request was accepted, raise the success event
onGetTeamProfileResponse(GetTeamProfileResponse);
}
else
{
//Something went wrong
if (onGetTeamProfileResponseError != null)
{
//Request failed, raise the error event
onGetTeamProfileResponseError(GetTeamProfileResponse);
}
}
}
catch
{
//Something went wrong
onGetTeamProfileResponseError(null);
}
}
}
}
Responses JSON, XML
JSON Response
{
"RootImageURL": "http://connecterstoredev.blob.core.windows.net/",
"TeamID": "2013-08-22 13:26:28.4496190",
"TeamName": "TestTeam",
"PublicKey": "",
"Apps": [
{
"AppID": 40,
"AppName": "Office Heroes",
"Description": "Do you have what it takes to be the hero of the office ????",
"IconURL": "https://connecterstoredev.blob.core.windows.net/apps/appicon_40_{s|m|l}.png",
"ValidatedDomain": "",
"ValidatedOrg": "",
"AppDomains": [
{
"AppDomainID": 63,
"ExternalAccountID": "TestGroup",
"ValidatedDomain": "",
"ValidatedOrg": "",
"IsPersonal": false,
"Badges": [
{
"BadgeID": 103,
"BadgeName": "Test",
"Description": "Test Badge that doesn't require an action trigger",
"Count": 1,
"IconURL": "https://connecterstoredev.blob.core.windows.net/badges/badgeicon_0_{s|m|l}.png",
"Expires": false,
"ExpirationDate": "2000-01-01 00:00:00.0000000",
"Modified": "2013-08-22T13:26:30.2807144Z",
"Unlocked": true,
"UserDisabled": false,
"UserDeleted": false
}
],
"Certs": [],
"Skills": [],
"UserLeaderboards": [],
"TeamLeaderboards": [],
"RewardPoints": 0
}
]
}
],
"Settings": [],
"Result": true,
"ResultTitle": "",
"ResultMessage": ""
}
XML Response
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="Connecter">
<Apps>
<App>
<AppDomains>
<AppDomain>
<AppDomainID>63</AppDomainID>
<Badges>
<Badge>
<BadgeID>103</BadgeID>
<BadgeName>Test</BadgeName>
<Count>1</Count>
<Description>Test Badge that doesn't require an action trigger</Description>
<ExpirationDate>2000-01-01 00:00:00.0000000</ExpirationDate>
<Expires>false</Expires>
<IconURL>
https://connecterstoredev.blob.core.windows.net/badges/badgeicon_0_{s|m|l}.png
</IconURL>
<Modified>2013-08-22T13:26:30.2807144Z</Modified>
<Unlocked>true</Unlocked>
<UserDeleted>false</UserDeleted>
<UserDisabled>false</UserDisabled>
</Badge>
</Badges>
<Certs />
<ExternalAccountID>TestGroup</ExternalAccountID>
<IsPersonal>false</IsPersonal>
<RewardPoints>0</RewardPoints>
<Skills />
<TeamLeaderboards />
<UserLeaderboards />
<ValidatedDomain />
<ValidatedOrg />
</AppDomain>
</AppDomains>
<AppID>40</AppID>
<AppName>Office Heroes</AppName>
<Description>
Do you have what it takes to be the hero of the office ????
</Description>
<IconURL>
https://connecterstoredev.blob.core.windows.net/apps/appicon_40_{s|m|l}.png
</IconURL>
<ValidatedDomain />
<ValidatedOrg />
</App>
</Apps>
<PublicKey />
<Result>true</Result>
<ResultMessage />
<ResultTitle />
<RootImageURL>http://connecterstoredev.blob.core.windows.net/</RootImageURL>
<Settings />
<TeamID>2013-08-22 13:26:28.4496190</TeamID>
<TeamName>TestTeam</TeamName>
</Response>
|
Use |
Runtime |
Method |
HTTP GET |
Invites User |
No |
Billable |
No |
Response |
JSON,XML |
API Version |
1 |
|