/// <summary> /// /// </summary> /// <param name="accessToken"></param> /// <param name="id"></param> /// <param name="timeInterVal"></param> public static void SchedulePagePost(string accessToken, string destinationPageId, string sourcePageId, int timeInterVal) { try { var timeIncrementer = 1; var cursorNext = string.Empty; do { var feeds = Fbpages.getFacebookPageRecentPost(accessToken, sourcePageId, cursorNext); if (string.IsNullOrEmpty(feeds) || feeds.Equals("[]")) { continue; } var fbPageNotes = JObject.Parse(feeds); try { cursorNext = fbPageNotes["paging"]["next"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.Message); cursorNext = "0"; } foreach (var obj in JArray.Parse(fbPageNotes["data"].ToString())) { try { var postId = obj["id"].ToString(); postId = postId.Split('_')[1]; var timestamp = DateExtension.ConvertToUnixTimestamp(DateTime.UtcNow.AddMinutes(timeInterVal * timeIncrementer)); var link = "https://www.facebook.com/" + sourcePageId + "/posts/" + postId; var pageAccessToken = FacebookApiHelper.GetPageAccessToken(destinationPageId, accessToken, string.Empty); var status = FacebookApiHelper.PublishPostOnSchedule(string.Empty, accessToken, destinationPageId, link, timestamp.ToString(CultureInfo.InvariantCulture)); if (status) { timeIncrementer++; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } while (cursorNext != "0"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }