0 purchases
post to facebook
post_to_facebook #
A Dart package for posting content to Facebook on behalf of a user or page.
Installation #
To use this package, add post_to_facebook as a dependency in your pubspec.yaml file:
dependencies:
post_to_facebook: ^0.0.1
copied to clipboard
Usage #
To use this package, you need to have a valid Facebook access token that has the publish_pages and/or publish_to_groups permissions, depending on the targets you want to post to. You can obtain an access token by creating a Facebook app, authorizing it with your Facebook account, and using the app ID and secret to generate a token via the Graph API Explorer.
Here's an example of how to use the post_to_facebook function:
import 'package:post_to_facebook/post_to_facebook.dart';
void main() async {
final accessToken = 'your-access-token';
final message = 'Hello, Facebook!';
final pageId= 'your-page-id';
try {
await postToFacebook(
accessToken: accessToken,
message: message,
pageId: pageId,
);
if (result.isSuccess) {
print(result.message);
} else {
print(result.message);
print('Response code: ${result.response?.statusCode}');
print('Response body: ${result.response?.body}');
}
} catch (e) {
print('Post failed with error: $e');
}
}
copied to clipboard
License #
This package is licensed under the BSD 3-clause license. See the LICENSE file for details.
Contributions #
Please file issues and feature requests in the GitHub repository. Contributions via pull requests are welcome and encouraged.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.