feedMeta = StructNew();
feedMeta.ServiceType = "twitter";
feedMeta.ServiceLink = "https://www.twitter.com/";
feedMeta.ServiceLogo = "/ADF/apps/pt_social_media/images/twitter-32.png"; // TODO: Get from config element
return feedMeta;
var objHttp = StructNew();
var feedError = false;
var feedErrorDetails = StructNew();
if ( feedError ) {
objHttp['feedError'] = feedError;
objHttp['errorDetails'] = feedErrorDetails;
objHttp['statusCode'] = "cfhttp error";
objHttp['feedURL'] = arguments.feedURL;
//Log the Error
doErrorLogging("twitter","getTwitterHTTPrequest",objHttp);
}
return objHttp;
var objHttp = StructNew();
var feedError = false;
var feedErrorDetails = StructNew();
var bearerToken = getTwitterEncodedBearerToken();
var authorizationCode = "Basic " & bearerToken;
var contentType = "application/x-www-form-urlencoded;charset=UTF-8";
if ( feedError ) {
objHttp['feedError'] = feedError;
objHttp['errorDetails'] = feedErrorDetails;
objHttp['statusCode'] = "cfhttp error";
objHttp['feedURL'] = arguments.feedURL;
//Log the Error
doErrorLogging("twitter","getTwitterAuthHTTPrequest",objHttp);
}
return objHttp;
var reData = StructNew();
var tokenKey = "access_token";
var tokenType = "token_type";
var delimiter = "=";
var tokenResponseData = StructNew();
var objHttp = getTwitterAuthHTTPrequest(feedURL=TRIM(arguments.feedURL),grantType=TRIM(arguments.grantType));
if ( IsStruct(objHttp) AND StructKeyExists(objHttp,"Statuscode") AND Find("200",objHttp.Statuscode) ) {
// check to see if objHttp.Filecontent is a json object
if ( StructKeyExists(objHttp,"Filecontent") AND IsJSON(objHttp.Filecontent) ) {
tokenResponseData = DeserializeJSON(objHttp.fileContent);
if ( StructKeyExists(tokenResponseData,tokenKey) AND LEN(TRIM(tokenResponseData[tokenKey])) ) {
reData['accessToken'] = tokenResponseData;
reData['tokenKey'] = tokenKey;
reData['tokenValue'] = tokenResponseData[tokenKey];
reData['tokenType'] = tokenResponseData[tokenType];
reData['authorization'] = tokenResponseData[tokenType] & " " & tokenResponseData[tokenKey];
reData['statuscode'] = objHttp.statuscode;
}
else {
reData['feedError'] = "fail: an #tokenKey# was not returned";
reData['feedURL'] = arguments.feedURL;
reData['fileContent'] = objHttp.Filecontent;
reData['statuscode'] = objHttp.statuscode;
}
}
else {
reData['feedError'] = "fail: JSON not Returned";
//reData['feedError'] = "fail: an #key# was not returned";
reData['feedURL'] = arguments.feedURL;
reData['fileContent'] = objHttp.Filecontent;
reData['statuscode'] = objHttp.statuscode;
}
}
else {
reData['feedError'] = "fail: connection error";
reData['feedURL'] = arguments.feedURL;
reData['fileContent'] = objHttp.Filecontent;
reData['statuscode'] = objHttp.statuscode;
}
// Log the Error if reData contains a feedError Key
if ( StructKeyExists(reData,"feedError") ) {
//Log the Error
doErrorLogging("twitter","getTwitterAuthFeed",reData);
}
return reData;
var feedData = StructNew();
var reStr = "";
var appConfigStruct = getAppConfig();
var apiURL = "";
// Default auth URL value... but get from the app config and use this only if the config vale does not exist
var defaultAuthURL = "https://api.twitter.com/oauth2/token";
// Get the Favebook API Auth URL from the config element
if ( StructKeyExists(appConfigStruct,"apiTwitterAuthTokenURL") AND LEN(TRIM(appConfigStruct.apiTwitterAuthTokenURL)) ) {
apiURL = appConfigStruct.apiTwitterAuthTokenURL;
//fix any character encoding from storing the API URLs in the config element
apiURL = Server.CommonSpot.UDF.data.FromHTML(apiURL);
}
else {
apiURL = defaultAuthURL;
}
// Get the Access Token
if ( LEN(TRIM(apiURL)) ) {
// Pass the generated FeedURL to the getTwitterAuthFeed method
feedData = getTwitterAuthFeed(feedURL=TRIM(apiURL),grantType=TRIM(arguments.grantType));
if ( IsStruct(feedData) AND StructKeyExists(feedData,"authorization") ) {
reStr = feedData.authorization;
}
else {
// Log the error
doErrorLogging("twitter","getTwitterAccessToken",reStr);
reStr = "";
}
}
return reStr;
var feedData = StructNew();
var reData = StructNew();
var objHttp = getTwitterHTTPrequest(feedURL=TRIM(arguments.feedURL),authCode=arguments.authCode);
var errorMsg = "fail: no results"; // Default Error Message
if ( StructKeyExists(objHttp,"Statuscode") AND Find("200",objHttp.Statuscode) ) {
/*if ( StructKeyExists(objHttp,"Filecontent") AND IsJSON(objHttp.Filecontent) ) {
feedData = deserializejson(objHttp.Filecontent);
}
else {
errorMsg = "fail: JSON not Returned";
}
if ( IsArray(feedData) AND ArrayLen(feedData) ) {
reData['results'] = feedData;
reData['statuscode'] = objHttp.statuscode;
}
else if ( IsStruct(feedData) AND StructKeyExists(feedData,"results") ) {
reData = feedData;
reData['statuscode'] = objHttp.statuscode;
}
else {
reData['feedError'] = errorMsg;
reData['feedURL'] = arguments.feedURL;
reData['fileContent'] = feedData;
reData['statusCode'] = objHttp.statuscode;
}
*/
if ( StructKeyExists(objHttp,"FileContent") AND IsJSON(objHttp.Filecontent) ) {
feedData = deserializejson(objHttp.Filecontent);
}
else {
errorMsg = "fail: JSON not Returned";
}
if ( IsArray(feedData) AND ArrayLen(feedData) ) {
// Posts Results Struct
reData['results'] = feedData;
reData['statuscode'] = objHttp.statuscode;
if ( StructKeyExists(objHttp,"Filecontent") )
reData['fileContent'] = feedData;
}
else if ( IsStruct(feedData) AND StructKeyExists(feedData,"statuses") ) {
// Search Results Struct
reData['results'] = feedData.statuses;
reData['statuscode'] = objHttp.statuscode;
if ( StructKeyExists(feedData,"search_metadata") )
reData['metadata'] = feedData.search_metadata;
//if ( StructKeyExists(objHttp,"Filecontent") )
// reData['fileContent'] = feedData;
}
else {
reData['feedError'] = errorMsg;
reData['feedURL'] = arguments.feedURL;
reData['fileContent'] = feedData;
reData['statusCode'] = objHttp.statuscode;
}
}
else {
reData['feedError'] = "fail: connection error";
reData['feedURL'] = arguments.feedURL;
if ( StructKeyExists(objHttp,"statuscode") )
reData['statuscode'] = objHttp.statuscode;
if ( StructKeyExists(objHttp,"Filecontent") )
reData['fileContent'] = objHttp.Filecontent;
}
// Log the Error if reData contains a feedError Key
if ( StructKeyExists(reData,"feedError") ) {
//Log the Error
doErrorLogging("twitter","getTwitterFeed",reData);
}
return reData;
//var feedURL = "http://search.twitter.com/search.json?q=";
var feedData = StructNew();
var reData = ArrayNew(1);
var appConfigStruct = getAppConfig();
var apiURL = "";
var feedURL = "";
var sTerm = "";
var snPrefix = "@";
var actPrefix = "##";
var replaceStr = "{{searchterm}}";
// Get API 1.1 authorization token
var authorization = getTwitterAccessToken();
// Remove the ## sign if one is passed with the search term
sTerm = ReplaceNoCase(arguments.searchTerm,actPrefix,"","one");
// Remove the @ sign if one is passed with the search term
sTerm = ReplaceNoCase(sTerm,snPrefix,"","one");
if ( StructKeyExists(appConfigStruct,"apiTwitterSearch") ) {
apiURL = appConfigStruct.apiTwitterSearch;
//fix any character encoding from storing URLs in the config element
apiURL = Server.CommonSpot.UDF.data.FromHTML(apiURL);
}
if ( Len(Trim(sTerm)) AND Len(Trim(apiURL)) ) {
if ( FindNoCase(replaceStr,apiURL) )
feedURL = ReplaceNoCase(apiURL,replaceStr,TRIM(sTerm),"one");
if ( Len(Trim(feedURL)) ) {
// Pass the generated FeedURL to the getTwitterFeed method
feedData = getTwitterFeed(feedURL=TRIM(feedURL),authCode=authorization);
}
// Add the feedData Results Array to the reData Array
if ( StructKeyExists(feedData,"results") AND IsArray(feedData.results) AND ArrayLen(feedData.results) ) {
reData = feedData.results;
}
else {
// No need to error just because there were no search results
//doErrorLogging("twitter","getTwitterSearchResults",feedData);
reData = ArrayNew(1);
}
}
// Log the error if reData is not returning the expected data types
if ( !IsArray(reData) ) {
doErrorLogging("twitter","getTwitterSearchResults",reData);
reData = ArrayNew(1);
}
return reData;
//var feedURL = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name={{screenname}}";
var feedData = StructNew();
var reData = ArrayNew(1);
var appConfigStruct = getAppConfig();
var apiURL = "";
var feedURL = "";
var sName = "";
var snPrefix = "@";
var actPrefix = "##";
var replaceStr = "{{screenname}}";
// Get API 1.1 authorization token
var authorization = getTwitterAccessToken();
// Remove the @ sign if one is passed with the screenName
sName = ReplaceNoCase(arguments.screenName,snPrefix,"","one");
// Remove the ## sign if one is passed with the screenName
sName = ReplaceNoCase(sName,actPrefix,"","one");
if ( StructKeyExists(appConfigStruct,"apiTwitterScreenName") ) {
apiURL = appConfigStruct.apiTwitterScreenName;
//fix any character encoding from storing URLs in the config element
apiURL = Server.CommonSpot.UDF.data.FromHTML(apiURL);
}
if ( Len(Trim(sName)) AND Len(Trim(apiURL)) ) {
if ( FindNoCase(replaceStr,apiURL) )
feedURL = ReplaceNoCase(apiURL,replaceStr,TRIM(sName),"one");
if ( Len(Trim(feedURL)) ) {
// Pass the generated FeedURL to the getTwitterFeed method
feedData = getTwitterFeed(feedURL=TRIM(feedURL),authCode=authorization);
}
// Add the feedData Results Array to the reData Array
if ( StructKeyExists(feedData,"results") AND IsArray(feedData.results) AND ArrayLen(feedData.results) ) {
reData = feedData.results;
}
else {
// Log the error
doErrorLogging("twitter","getTwitterPosts",feedData);
reData = ArrayNew(1);
}
}
// Log the error if reData is not returning the expected data types
if ( !IsArray(reData) ) {
doErrorLogging("twitter","getTwitterPosts",reData);
reData = ArrayNew(1);
}
return reData;