Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow posting content to Facebook Pages (#353) #354

Merged
merged 12 commits into from
Nov 6, 2020

Conversation

pbek
Copy link
Contributor

@pbek pbek commented Nov 2, 2020

Implements #353

@pbek
Copy link
Contributor Author

pbek commented Nov 2, 2020

Needs more work, because I used mod.session.Post and that seems to also validate the access token (which expires after one hour). So I'll have to do the POST by hand. 😬

2020-11-02T19:02:13.865106254Z INFO[2111] [Facebook 3]: Attempting to post "New release of QOwnNotes: v20.11.1: https://www.qownnotes.org/changelog.html#_20-11-1 #QOwnNotes #ownCloud #Nextcloud" to Facebook Page "1079606388736701" 
2020-11-02T19:02:13.911774545Z ERRO[2111] [Facebook 3]: Error: [message:Error validating access token: Session has expired on Monday, 02-Nov-20 10:00:00 PST. The current time is Monday, 02-Nov-20 11:02:27 PST.] [type:OAuthException] [code:190] [subcode:463] 

@pbek
Copy link
Contributor Author

pbek commented Nov 2, 2020

And the token is not a permanent one...

  1. We currently only have a Short-lived User Access Token that is valid for one hour (user interaction required).
  2. You need 1) to get a Long-lived User Access Token (valid 60 days), request can be made in the background
  3. You need 2) to get a Permanent token, request can be made in the background

@pbek
Copy link
Contributor Author

pbek commented Nov 2, 2020

@pbek
Copy link
Contributor Author

pbek commented Nov 2, 2020

Needs more work, because I used mod.session.Post and that seems to also validate the access token (which expires after one hour). So I'll have to do the POST by hand. grimacing

2020-11-02T19:02:13.865106254Z INFO[2111] [Facebook 3]: Attempting to post "New release of QOwnNotes: v20.11.1: https://www.qownnotes.org/changelog.html#_20-11-1 #QOwnNotes #ownCloud #Nextcloud" to Facebook Page "1079606388736701" 
2020-11-02T19:02:13.911774545Z ERRO[2111] [Facebook 3]: Error: [message:Error validating access token: Session has expired on Monday, 02-Nov-20 10:00:00 PST. The current time is Monday, 02-Nov-20 11:02:27 PST.] [type:OAuthException] [code:190] [subcode:463] 

I fixed that one. It all works well now with an expired user access token, but manually getting a permanent page token is still inconvenient.

@pbek
Copy link
Contributor Author

pbek commented Nov 3, 2020

Automatic permanent page access token generating and storing are working now!

The pull request is now ready for inspection and merging, @muesli!

Copy link
Owner

@muesli muesli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, we just could/should improve the error handling a bit.

bees/facebookbee/facebookbee.go Outdated Show resolved Hide resolved
bees/facebookbee/facebookbee.go Outdated Show resolved Hide resolved
bees/facebookbee/facebookbee.go Outdated Show resolved Hide resolved
bees/facebookbee/facebookbee.go Show resolved Hide resolved
@pbek
Copy link
Contributor Author

pbek commented Nov 6, 2020

@muesli, I improved the error handling and created an inline struct. Thank you for the helpful feedback... New things I learned. 😁

@muesli muesli merged commit f1c355b into muesli:master Nov 6, 2020
@muesli
Copy link
Owner

muesli commented Nov 6, 2020

Thank you!

@pbek
Copy link
Contributor Author

pbek commented Nov 6, 2020

Thank you for all your feedback!

@pbek pbek deleted the feature/facebook-page-post-content branch November 6, 2020 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants