Pages - Access Request
Access request is the way to manage access for a private page. A private page is visible for all user but content not. You need to be member and to be member you may make a request.
Page Access Request
To create a page you have to make a HTTP POST request with parameters in JSON form. There are some required parameters for this operation:
- page_id
string
: Relate to the page id. - user_id
string
: Relate to the user id.
- Bash
- Python
- Node.js
- Ruby
- PHP
curl -X POST \https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/page_access_requests \-H 'Api-Key: YOUR_API_KEY' \-H 'Api-Secret: YOUR_API_SECRET' \-H 'Content-Type: application/json' \-d '{"page_id": "PAGE_ID","user_id": "USER_ID"}'
Please note a user cannot send a request if he have already an waiting request. Of course if it is already in private page, he can't send a request.
List access requests
You can list all requests by two methods:
The first is with a HTTP GET request on page access requests API point.
- Bash
- Python
- Node.js
- Ruby
- PHP
curl -X GET \https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/page_access_requests \-H 'Api-Key: YOUR_API_KEY' \-H 'Api-Secret: YOUR_API_SECRET' \-H 'Content-Type: application/json' \The second is by page endpoint
- Bash
- Python
- Node.js
- Ruby
- PHP
curl -X GET \https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/pages/PAGE_ID/page_access_requests \-H 'Api-Key: YOUR_API_KEY' \-H 'Api-Secret: YOUR_API_SECRET' \-H 'Content-Type: application/json' \
You can pass params to filter:
- user_id
string
: To have access requests of user. - state
string
: State of access request. It can be accepted or waiting - page_id
string
: To have access requests of page. Available only on first method The response will look like this
{"items":[{"id":"2e8dd42ac25c473e958ec49799e43cf4","user": {"id":"7897f877a6eded28a6166340b191a896c9d67dbf","nickname":"JohnDoe",...},user_id: "7897f877a6eded28a6166340b191a896c9d67dbf"page: {"id":"2e8dd42ac25c473e958ec49799e43cf4","name":"My First User","slug":"my-first-page",...},page_id:"2e8dd42ac25c473e958ec49799e43cf4"is_validate: false,created_at: "2019-12-27T09:50:58.000+01:00",updated_at: "2020-01-02T16:18:42.000+01:00"},{"id":"2e8dd42ac25c473e958ec49799e43cf4","user": {"id":"ae31828c3e7d4c3482cd4fcf11a0ccc1","nickname":"JeanDupont",...},user_id: "ae31828c3e7d4c3482cd4fcf11a0ccc1"page: {"id":"7bf9a28647384196b6db238603cf245e","name":"My Second Page","slug":"my-second-page",...},page_id:"7bf9a28647384196b6db238603cf245e"is_validate: false,created_at: "2019-12-27T09:50:58.000+01:00",updated_at: "2020-01-02T16:18:42.000+01:00"}],"total_items":2}
Accept or refuse an access request
Now you have method to get and create access requests, you have to accept or refuse it. When you accept it, the flag is_validate is passed to true. A follow for page is automaticly created.
- Bash
- Python
- Node.js
- Ruby
- PHP
curl -X PUT \https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/page_access_requests/:ID/accept \-H 'Api-Key: YOUR_API_KEY' \-H 'Api-Secret: YOUR_API_SECRET' \-H 'Content-Type: application/json' \
If you refuse it, access request will be deleted.
- Bash
- Python
- Node.js
- Ruby
- PHP
curl -X PUT \https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/page_access_requests/:ID/refuse \-H 'Api-Key: YOUR_API_KEY' \-H 'Api-Secret: YOUR_API_SECRET' \-H 'Content-Type: application/json' \
Note: If you check right, only administrator of page can accept or refuse it.
Webhooks
You can configure an url in webhook. You will have a webhook when an access request is created, updated or deleted