Created
April 29, 2018 17:33
-
-
Save RetiredQQ/2b559135896ab2d57f7fb67adacf390b to your computer and use it in GitHub Desktop.
Simple Auto Update Facebook Status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Dynamic; | |
using System.Threading; | |
using Facebook; | |
namespace Auto_Update_Status_Facebook | |
{ | |
class Program | |
{ | |
static FacebookClient FBClient; | |
static string LastErrorText; | |
public static void Main(string[] args) | |
{ | |
Console.Title = "Auto Update Facebook Status"; | |
int delay = 10000; // 60 seconds before next status. Recommended is 1 hours. | |
// Set your access token here | |
FBClient = new FacebookClient("EAACEd..............."); | |
// Your quotes here | |
// https://gist.github.com/christianvuerings/6624542 | |
string[] messages = | |
{ | |
"Things may come to those who wait, but only the things left by those who hustle. - Abraham Lincoln", | |
"The great secret of education is to direct vanity to proper objects. - Adam Smith", | |
"It’s not that travel just broadens your mind, rather it enables you to see how narrow your oppressor’s minds are. - Alain de Botton" | |
}; | |
for (int i = 0; i < messages.Length; i++) | |
{ | |
Console.Clear(); | |
var msg = messages[i]; | |
var success = PostMessage(msg); | |
if (!success) | |
{ | |
Console.WriteLine(LastErrorText); | |
} | |
else | |
{ | |
Console.WriteLine("Posted status: " + msg); | |
} | |
Thread.Sleep(delay); | |
} | |
Console.ReadKey(); | |
} | |
static bool PostMessage(string msg) | |
{ | |
bool result; | |
try | |
{ | |
dynamic expandoObj = new ExpandoObject(); | |
expandoObj.message = msg; | |
FBClient.Post("/me/feed", expandoObj); | |
result = true; | |
} | |
catch (Exception ex) | |
{ | |
LastErrorText = ex.Message; | |
result = false; | |
} | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment