Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boly38/testfb
Quickstart to post on Facebook (FB) using FB API
https://github.com/boly38/testfb
curl facebook facebook-api hacktoberfest howto nodejs quickstart
Last synced: about 1 month ago
JSON representation
Quickstart to post on Facebook (FB) using FB API
- Host: GitHub
- URL: https://github.com/boly38/testfb
- Owner: boly38
- Created: 2023-10-27T18:39:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-28T19:01:06.000Z (about 1 year ago)
- Last Synced: 2024-10-05T06:30:05.347Z (about 2 months ago)
- Topics: curl, facebook, facebook-api, hacktoberfest, howto, nodejs, quickstart
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# testFB
Quickstart to post on FB using FB API
https://developers.facebook.com/docs#apis-and-sdks* this project requires a page name + page access token (short or long lived one)
* this project produces 2 curl commands : get page, and post a simple message on a pageIn addition with an application-id and application-secret, and access token (short or long-lived one) :
* this project produces a curl command to get or recycle long-lived access token## HowTo
### requirements
* nodeJS & curl installed
### context data
You need a **page name**:
- pick it from page uri : https://facebook.com/myPageNameHere````bash
# page id
export FB_PAGE_ID=myPageNameHere
````You need **a valid page access token** :
- to generate a token, use [tools/explorer](https://developers.facebook.com/tools/explorer).
- to verify a token, use [tools/debug/accesstoken](https://developers.facebook.com/tools/debug/accesstoken/) : check scope and expiration date.By default, a FB login result is a short-lived access-token : expiration is ~1 hour.
To get long-lived access-token, you must call a dedicated API. Long-lived access-token expiration is ~2 months
````bash
# page access token
export FB_ACCESS_TOKEN=xxxxx
````You could print current FB env values :
````bash
# check current env
env|grep FB_
````or clean them, for example:
````bash
unset FB_PAGE_ID FB_ACCESS_TOKEN
````(in option) You need an **application id** and **application secret** in order to get long-lived token:
````bash
export FB_APP_id=0000000
export FB_APP_SECRET=0a0a0a0a0a
````
Nb: pick them from [developers.facebook.com/apps](https://developers.facebook.com/apps/)### usage
````bash
node printCurlCommands
# this app only SHOWS curl commands
# then it's up to you to copy/paste curl command you want to try
````* see more info in [source code](./printCurlCommands.js)
---
See also : (failed) [testInsta](https://github.com/boly38/testInsta)