{"id":129,"date":"2022-11-19T06:31:02","date_gmt":"2022-11-19T11:31:02","guid":{"rendered":"https:\/\/daveking.com\/blog\/?p=129"},"modified":"2022-11-26T11:49:59","modified_gmt":"2022-11-26T16:49:59","slug":"automating-facebook-profile-posts","status":"publish","type":"post","link":"https:\/\/daveking.com\/blog\/index.php\/2022\/11\/19\/automating-facebook-profile-posts\/","title":{"rendered":"Automating Facebook Profile Posts"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em><strong>UPDATE:<\/strong> I refactored this into a systemd.socket-driven service, rather than a Python Flask web service.  This means that the script only runs when systemd receives a request on the assigned port, saving the overhead of running a Flask service script in background full time.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I want WordPress to make a post to my Facebook profile when I publish a new WordPress post. All the WordPress plugins for Facebook use the official Facebook API which only supports posting to a Facebook <strong>page<\/strong>. I didn&#8217;t want that. I want my posts to go into my profile\/timeline. I&#8217;ve written a hack that does what I want by using an application user interface testing tool to drive a live browser session on my workstation to make a Facebook profile post whenever I publish a new WordPress post.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Florian Domgjoni pointed the way on&nbsp;<a href=\"https:\/\/python.plainenglish.io\/automating-facebook-posts-with-python-using-selenium-7a7ffca0f325\">Python In Plain English<\/a>. There he described using the&nbsp;<a href=\"https:\/\/selenium-python.readthedocs.io\/\">Python Selenium UI test automation tool<\/a>&nbsp;to automate a browser session to make Facebook posts. Thanks Florian!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I took Florian&#8217;s script and turned it into a&nbsp;Python script that is invoked upon demand by a systemd.socket service. I installed a webhooks plugin in my WordPress instance out on the internet that sends a message to that systemd service each time I publish a new WordPress post. The script then makes a corresponding post to my Facebook profile.  Now it does what I want.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve set up <a href=\"https:\/\/github.com\/dlk3\/fbpost\">a github repo<\/a> with the code and a write-up on how I set this up.  Check it out if you&#8217;re interested.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Making WordPress autopost to my Facebook profile (not a Facebook page) when I make a new blog post.<\/p>\n","protected":false},"author":1,"featured_media":123,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[22],"tags":[23,12],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howto","tag-howto","tag-software","eq-blocks"],"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/daveking.com\/blog\/wp-content\/uploads\/2022\/11\/facebook.jpg?fit=1600%2C900&ssl=1","_links":{"self":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":3,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions\/197"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/123"}],"wp:attachment":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}