var feedArray = ArrayNew(1);
var feedData = StructNew();
var feedPageInfo = StructNew();
var feedStream = ArrayNew(1);
var feedService = StructNew();
var postQty = arguments.maxPosts;
var userData = StructNew();
var dt = "";
var postID = "";
// Get the the Facebook feeds from the registered URL
feedPageInfo = application.ptSocialMedia.facebookFeedsDAO.getFacebookPageInfo(TRIM(arguments.feedCriteria));
feedStream = application.ptSocialMedia.facebookFeedsDAO.getFacebookPagePosts(TRIM(arguments.feedCriteria));
if ( arguments.showFeedDump ) {
application.ptSocialMedia.utils.doDUMP(feedPageInfo,"Facebook-feedPageInfo (#arguments.FeedID#)",0);
application.ptSocialMedia.utils.doDUMP(feedStream,"Facebook-feedStream (#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++ ) {
PostID = "";
if ( StructKeyExists(feedStream[d],"id") )
PostID = feedStream[d].id;
// Do not Build a Feed Data Struct for Posts that are part of the Excluded Posts List
if ( ListFindNoCase(arguments.excludedPostIDs,PostID) EQ 0 ) {
// 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.facebookFeedsDAO.getFacebookMetadata();
StructAppend(feedData,feedService,true);
// Feed ID
feedData.FeedID = arguments.FeedID;
// Feed Type
if ( StructKeyExists(feedStream[d],"type") )
feedData.FeedType = feedStream[d].type;
// Facebook Page Name (from Page Info Feed)
if ( StructKeyExists(feedPageInfo,"name") )
feedData.FeedName = feedPageInfo.name;
// Facebook Page Image (from Page Feed)
// -- Page Info Image is not a standard size
//if ( StructKeyExists(feedPageInfo,"picture") )
//feedData.FeedImage = feedPageInfo.picture;
// Facebook Page Image (from Page Info Feed)
if ( StructKeyExists(feedPageInfo,"id") )
feedData.FeedImage = application.ptSocialMedia.facebookFeedsDAO.getFacebookImageURL(feedPageInfo.id);
// Facebook Page Link (from Page Feed)
if ( StructKeyExists(feedPageInfo,"link") )
feedData.FeedLink = feedPageInfo.link;
// Published Dates
if ( StructKeyExists(feedStream[d],"created_time") ) {
dt = Application.ptSocialMedia.date.ISOToDateTimeStruct(feedStream[d].created_time);
feedData.PublishedDate = dt.ISO8601DateTime;
feedData.csFormattedPublishedDate = dt.csDateTime;
feedData.Content.Date = dt.ISO8601DateTime;
feedData.Content.CSFormattedDate = dt.csDateTime;
//feedData.PublishedDate = feedStream[d].created_time;
//dt = Application.ptSocialMedia.date.ISOToDateTime(feedData.PublishedDate);
//feedData.csFormattedPublishedDate = Application.ptSocialMedia.date.csDateFormat(DateFormat(dt),TimeFormat(dt));
//feedData.CONTENT.DATE = feedData.PublishedDate;
//feedData.CONTENT.CSFORMATTEDDATE = feedData.csFormattedPublishedDate;
}
// Post Source Info
if ( StructKeyExists(feedStream[d],"from") ) {
// Source Name
if ( StructKeyExists(feedStream[d].from,"name")) {
feedData.Source.USERNAME = feedStream[d].from.name;
feedData.Source.Name = feedStream[d].from.name;
}
// Source Description
if ( StructKeyExists(feedStream[d].from,"category"))
feedData.Source.DESCRIPTION = feedStream[d].from.category;
if ( StructKeyExists(feedStream[d].from,"id")) {
// Source User ID
feedData.Source.userid = feedStream[d].from.id;
// Get Additional User Data
userData = application.ptSocialMedia.facebookFeedsDAO.getFacebookUserData(feedData.Source.userid);
feedData.Source.Photo = application.ptSocialMedia.facebookFeedsDAO.getFacebookImageURL(feedData.Source.userid);
// Source Photo URL
//if ( StructKeyExists(userData,"picture") )
//feedData.Source.Photo = ""; // this value is the (s)userData.picture;
//else
//feedData.Source.Photo = application.ptSocialMedia.facebookFeedsDAO.getFacebookImageURL(feedData.Source.userid);
if ( StructKeyExists(userData,"link") )
feedData.Source.link = userData.link;
}
}
/* if ( feedData.FeedType IS "status" ) {
// Post Source Info ( Status )
} else if ( feedData.FeedType IS "link" ) {
// Post Source Info ( link )
} */
// Post Content
// Content Post ID (ID)
feedData.Content.PostID = PostID;
// Content Title (Name)
if ( StructKeyExists(feedStream[d],"name") )
feedData.Content.Title = feedStream[d].name;
// Content Message (Message)
if ( StructKeyExists(feedStream[d],"message") ) {
feedData.Content.Message = feedStream[d].message;
//feedData.Content.Message = Application.ptSocialMedia.data.activateURL(strText=feedStream[d].message,target="_blank",paragraph="false");
}
// Content Description (description)
if ( StructKeyExists(feedStream[d],"description") )
feedData.Content.Description = feedStream[d].description;
// Content Link (Link)
if ( StructKeyExists(feedStream[d],"link") )
feedData.Content.Link = feedStream[d].link;
// Content Thumbnail (picture)
if ( StructKeyExists(feedStream[d],"picture") )
feedData.Content.Thumbnail = feedStream[d].picture;
// Content Icon (icon)
if ( StructKeyExists(feedStream[d],"icon") )
feedData.Content.icon = feedStream[d].icon;
// 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;
}
// Twitter Tweet Text
if ( LEN(TRIM(feedData.Content.Title)) )
feedData.TweetBtn.message = Left(feedData.Content.Title,120);
else if ( LEN(TRIM(feedData.Content.message)) )
feedData.TweetBtn.message = Left(feedData.Content.message,120);
else if ( LEN(TRIM(feedData.Content.description)) )
feedData.TweetBtn.message = Left(feedData.Content.description,120);
// Add feedData Data Struct to the feedArray Data Array
ArrayAppend(feedArray,feedData);
}
}
}
return feedArray;
var pName = "";
var paramPos = 0;
var feedPos = 0;
// Get the FB PAGE NAME from the submitted URL
pName = arguments.pageURL;
// 1) Strip any URL parameters
paramPos = FindNoCase("?",pName);
if ( paramPos )
pName = ListFirst(pName,"?");
// 2) remove the 'feed' Subfolder, if needed
feedPos = ListFindNoCase(pName,"feed","/");
if ( feedPos GT 0 )
pName = ListDeleteAt(pName,feedPos,"/");
// 3) get the last part of the URL, which should be the pageName
pName = ListLast(pName,"/");
return TRIM(pName);