var feedArray = ArrayNew(1); var feedData = StructNew(); var feedStream = ArrayNew(1); var feedService = StructNew(); var postQty = arguments.maxPosts; var dt = ""; var postID = ""; var buildOp = ""; // Get the the Twitter feed form the designated Account if ( arguments.feedType EQ "account" ) feedStream = application.ptSocialMedia.twitterFeedsDAO.getTwitterPosts(arguments.feedCriteria); else if ( arguments.feedType EQ "keyword" ) feedStream = application.ptSocialMedia.twitterFeedsDAO.getTwitterSearchResults(arguments.feedCriteria); // Feed Dump Option if ( arguments.showFeedDump ) application.ptSocialMedia.utils.doDUMP(feedStream,"TwitterFeedStream (#arguments.FeedID#)",0); // Make sure the feedStream data is an Array if ( IsArray(feedStream) ) { if ( ArrayLen(feedStream) LT arguments.maxPosts ) { postQty = ArrayLen(feedStream); } for ( d=1; d LTE postQty; d=d+1 ) { postID = ""; if ( StructKeyExists(feedStream[d],"id_str") ) { postid = feedStream[d].id_str; } if (arguments.filtertype EQ "excluded") // Do not Build a Feed Data Struct for Posts that are part of the Excluded Posts List buildOp = ListFindNoCase(arguments.filteredPostIDs, PostID) NEQ 0; else // Build a Feed Data Struct for Posts that are part of the included Posts List buildOp = ListFindNoCase(arguments.filteredPostIDs, PostID) EQ 0; // Do not Build a Feed Data Struct for Posts that are part of the Excluded Posts List if ( buildOp ) { // Build the empty feed data structure feedData = Application.ptSocialMedia.feedController.buildFeedDataFormat(); // Fill in the feedData structure with the post info // General Post Metadata feedService = Application.ptSocialMedia.twitterFeedsDAO.getTwitterMetadata(); StructAppend(feedData,feedService,true); // Feed ID feedData.FeedID = arguments.FeedID; // Feed Type feedData.FeedType = lcase(arguments.feedType); // Feed Name feedData.FeedName = arguments.feedCriteria; // Feed Status if ( StructKeyExists(feedStream[d],"FeedStatus") ) { feedData.FeedStatus = feedStream[d].FeedStatus; } // Feed User Info if ( StructKeyExists(feedStream[d],"user") ) { // Twitter FeedImage ( USER profile_image_url ) if ( StructKeyExists(feedStream[d].user,"profile_image_url") ) feedData.FeedImage = feedStream[d].user.profile_image_url; } // Feed Link feedData.FeedLink = getTwitterProfileURL(screenName=arguments.feedCriteria); // Published Dates if ( StructKeyExists(feedStream[d],"created_at") ) { dt = feedStream[d].created_at; // 2013-06-20 - GAC - Updated for Twitter API 1.1... no londer uses DayAbbr Comma DayNum Month Year Time Offset. Now uses: DayAbbr Month DayNum Time Offset Year dt = application.ptSocialMedia.twitterAPI.twitterDateTimeParser(dt); dt = application.ptSocialMedia.date.ISOToDateTimeStruct(dt); feedData.PublishedDate = dt.ISO8601DateTime; feedData.csFormattedPublishedDate = dt.csDateTime; feedData.Content.Date = dt.ISO8601DateTime; feedData.Content.CSFormattedDate = dt.csDateTime; } // Post Source Info ( Keyword Search ) if ( StructKeyExists(feedStream[d],"from_user_id_str") ) { feedData.Source.userid = feedStream[d].from_user_id_str; } // Post Source Info ( Screen Name / Account ) if ( StructKeyExists(feedStream[d],"user") ) { // Post Creator Info if ( StructKeyExists(feedStream[d].user,"name") ) { feedData.Source.Name = feedStream[d].user.name; } if ( StructKeyExists(feedStream[d].user,"profile_image_url") ) { feedData.Source.Photo = feedStream[d].user.profile_image_url; } if ( StructKeyExists(feedStream[d].user,"id_str") ) { feedData.Source.userid = feedStream[d].user.id_str; // TODO: get user's twitter page URL from id_str //feedData.Source.link = feedStream[d].user.id_str; } if ( StructKeyExists(feedStream[d].user,"screen_name") ) { feedData.Source.username = "@" & feedStream[d].user.screen_name; } if ( StructKeyExists(feedStream[d].user,"description") ) { feedData.Source.description = feedStream[d].user.description; } // Use the Profile URL from username Function if ( LEN(TRIM(feedData.Source.username)) ) { //feedData.Source.link = "http://twitter.com/" & feedData.Source.username; feedData.Source.link = getTwitterProfileURL(screenName=feedData.Source.username); } } // Post Content if ( LEN(TRIM(postid)) ) { feedData.Content.postid = postid; //TODO: Add to config element and s Status Function if ( LEN(TRIM(feedData.Source.username)) ) feedData.Content.link = getTwitterTweetURL(screenName=feedData.Source.username,twitterID=postid); } if ( StructKeyExists(feedStream[d],"full_text") and len(feedStream[d].full_text) ) { feedData.Content.message = feedStream[d].full_text; } else if ( StructKeyExists(feedStream[d],"text") and len(feedStream[d].text) ) { feedData.Content.message = feedStream[d].text; } //feedData.Content.message = Application.ptSocialMedia.data.activateURL(strText=feedStream[d].text,target="_blank",paragraph="false"); if ( StructKeyExists(feedStream[d].entities,"media") ) { feedData.Content.thumbnail = feedStream[d].entities.media[1].media_url_https; } else if ( StructKeyExists(feedStream[d],"quoted_status") ) { if ( StructKeyExists(feedStream[d].quoted_status.entities,"media") ) { feedData.Content.thumbnail = feedStream[d].quoted_status.entities.media[1].media_url_https; } } // FB Like and Twitter Tweet Buttons if ( LEN(TRIM(feedData.Content.Link)) ) { feedData.FBLikeBtn.link = feedData.Content.Link; feedData.TweetBtn.link = feedData.Content.Link; } else if ( LEN(TRIM(feedData.Source.Link)) ) { feedData.FBLikeBtn.link = feedData.Source.Link; feedData.TweetBtn.link = feedData.Source.Link; } else { feedData.FBLikeBtn.link = feedData.FEEDLINK; feedData.TweetBtn.link = feedData.FEEDLINK; } if ( LEN(TRIM(feedData.Content.message)) ) { feedData.TweetBtn.message = Left(feedData.Content.message,120); } ArrayAppend(feedArray,feedData); } // END - IF buildOp is true (filtered Post IDs) } // END - FOR Loop } // END - IsArray return feedArray; var appConfigStruct = getAppConfig(); var profileURL = ""; var apiURL = ""; var sName = ""; var hashPrefix = "##"; var replaceStr = "{{screenname}}"; // Remove the @ sign if one is passed in with the screenName sName = stripAT(handleStr=arguments.screenName); // If a ## sign is found it is not a screenName if ( FindNoCase(hashPrefix,sName) ) sName = ""; // Default: http://www.twitter.com/{{screenname}} if ( StructKeyExists(appConfigStruct,"apiTwitterProfileURL") ) { apiURL = appConfigStruct.apiTwitterProfileURL; //fix any character encoding from storing URLs in the config element apiURL = Server.CommonSpot.UDF.data.FromHTML(apiURL); } // Use the screenName in the API URL if ( Len(Trim(sName)) AND Len(Trim(apiURL)) ) { // Replace the {{screenname}} with the passed in page name if ( FindNoCase(replaceStr,apiURL) ) profileURL = ReplaceNoCase(apiURL,replaceStr,sName,"one"); } return profileURL; var appConfigStruct = getAppConfig(); var tweetPageURL = ""; var apiURL = ""; var sName = ""; var twID = ""; var hashPrefix = "##"; var snReplaceStr = "{{screenname}}"; var idReplaceStr = "{{twitterid}}"; var snReplace = false; var idReplace = false; // Make sure we have twitter handle passed in if ( LEN(TRIM(arguments.screenName)) ) { // Remove the @ sign if one is passed in with the screenName sName = stripAT(handleStr=arguments.screenName); // If a ## sign is found it is not a screenName if ( FindNoCase(hashPrefix,sName) ) sName = ""; } // Make sure we have twitter post ID passed in if ( LEN(TRIM(arguments.twitterID)) ) twID = arguments.twitterID; // Default: http://www.twitter.com/{{screenname}} if ( StructKeyExists(appConfigStruct,"apiTwitterTweetURL") ) { apiURL = appConfigStruct.apiTwitterTweetURL; //fix any character encoding from storing URLs in the config element apiURL = Server.CommonSpot.UDF.data.FromHTML(apiURL); } // make sure we have a API URL value if ( Len(Trim(apiURL)) ) { // Use the screenName in the API URL if ( Len(Trim(sName)) ) { // Replace the {{screenname}} with the passed in screen name if ( FindNoCase(snReplaceStr,apiURL) ) { apiURL = ReplaceNoCase(apiURL,snReplaceStr,sName,"one"); snReplace = true; } } // Use the twitter post ID in the API URL if ( Len(Trim(twID)) ) { tweetPageURL = apiURL; // Replace the {{twitterid}} with the passed in twitter post id if ( FindNoCase(idReplaceStr,apiURL) ) { apiURL = ReplaceNoCase(apiURL,idReplaceStr,twID,"one"); idReplace = true; } } if ( snReplace AND idReplace ) tweetPageURL = apiURL; } return tweetPageURL; var hPrefix = "@"; // Remove the @ sign if one is passed in with the screenName return ReplaceNoCase(arguments.handleStr,hPrefix,"","one"); var hPrefix = "##"; // Remove the pound sign if one is passed in with the screenName return ReplaceNoCase(arguments.hashTagStr,hPrefix,"","one");