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 = ""; var buildOp = ""; var appConfigStruct = application.ptSocialMedia.getAppConfig(); if ( structKeyExists(appConfigStruct,"filterType") AND LEN(TRIM(appConfigStruct['filterType'])) ) var filterType = appConfigStruct['filterType']; //application.ptSocialMedia.utils.doDUMP(arguments,"facebookFeedsService - buildFacebookFeedData arguments",0); // Get the basic info about the registered account feedPageInfo = application.ptSocialMedia.facebookFeedsDAO.getFacebookPageInfo(feedID=feedID); // Get the the Facebook feeds from the registered account feedStream = application.ptSocialMedia.facebookFeedsDAO.getFacebookFeed(feedID=feedID,maxPosts=maxPosts).data; // Determine post filter operator from chosen mode from app configuration if ( arguments.showFeedDump ) { application.ptSocialMedia.utils.doDUMP(feedPageInfo,"Facebook-feedPageInfo (#arguments.FeedID#)",0); application.ptSocialMedia.utils.doDUMP(feedStream,"Facebook-feedStream (#arguments.FeedID#)",0); } //application.ptSocialMedia.utils.doDUMP(arguments,"arguments (#arguments.FeedID#)",0); //application.ptSocialMedia.utils.doDUMP(feedStream,"buildFacebookFeedData - 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; /*if (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; //writeoutput("buildOp: #buildOp#
"); } else { // Build a Feed Data Struct for Posts that are part of the included Posts List buildOp = ListFindNoCase(arguments.filteredPostIDs, PostID) EQ 0; //writeoutput("buildOp: #buildOp#
"); }*/ /*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.facebookFeedsDAO.getFacebookMetadata(); StructAppend(feedData, feedService, true); // Feed ID feedData.FeedID = arguments.FeedID; // Feed Type feedData.FeedType = "status update"; // Facebook Page Name (from Page Info Feed) if (StructKeyExists(feedPageInfo, "name")) feedData.FeedName = feedPageInfo.name; // 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; // 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; } // 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; // Content Description (description) if (StructKeyExists(feedStream[d], "description")) feedData.Content.Description = feedStream[d].description; // Content Link (Link) if (StructKeyExists(feedStream[d], "link") AND len(feedStream[d].link)) { feedData.Content.Link = feedStream[d].link; } else { feedData.Content.Link = application.ptSocialMedia.facebookFeedsDAO.getFacebookPostURL(feedID,postID); } // Content Full Picture from Post or scrapped from link in post if (StructKeyExists(feedStream[d], "full_picture")) { feedData.Content.fullPicture = feedStream[d].full_picture; } // Content Thumbnail (picture) //feedData.Content.Thumbnail = feedStream[d].picture; if (StructKeyExists(feedStream[d], "attachments")){ attachmentsStruct = feedStream[d].attachments.data[1]; if (StructKeyExists(attachmentsStruct, "subattachments")){ subAttachmentsStruct = attachmentsStruct.subattachments.data[1]; if (StructKeyExists(subAttachmentsStruct, "media")) feedData.Content.Thumbnail = subAttachmentsStruct.media.image.src; else feedData.Content.Thumbnail = ""; } else { if (StructKeyExists(attachmentsStruct, "media")) feedData.Content.Thumbnail = attachmentsStruct.media.image.src; else feedData.Content.Thumbnail = ""; if (StructKeyExists(attachmentsStruct, "title")) feedData.Content.Title = attachmentsStruct.title; else feedData.Content.Title = ""; } } // 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); } /*}*/ } } //application.ptSocialMedia.utils.doDUMP(feedArray,"buildFacebookFeedData - feedArray (#arguments.FeedID#)",0); 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);