Create new forum via API
Hi Kaj,
Do you still have plans to extend the API to be able to create new forums programmatically. It's a feature I really need to allow easy extension of my training platform. Thanks for checking.
BR,
Franz
- In reply tofas⬆:KajMagnus @KajMagnus2021-12-21 04:33:56.670Z
Yes. How would you want to tell Talkyard who the owner of the new site will be? Should that be part of the API request, e.g. the new site owner's email address? (Or can you think of other ways to do this?)
- KajMagnus @KajMagnus2021-12-31 12:14:14.856Z
Hi Franz, started with this just recently. Happy new year in advance :- )
- In reply tofas⬆:KajMagnus @KajMagnus2022-01-20 15:07:42.890Z2022-01-20 15:20:21.161Z
Hi Franz, this has now been implemented
(and is available in the Ty .net SaaS-hosted sites, and in the self hosted release channel tomorrow Friday I would think).Here's how it works:
curl -X POST http://localhost/-/v0/create-site \ -H 'Content-Type: application/json' -H 'Authorization: Basic Y3JlY.........Y3JldA==' \ -d '{ // "testSiteOkDelete":true, "acceptTermsAndPrivacy":true, "localHostname":"comments-site-12345", "createEmbeddedComments":true, "embeddingSiteAddress": "https://your-blog.example.com", "organizationName":"E2E Test Create Site Via Api", "ownerUsername":"owen_owner", "ownerEmailAddr":"e2e-test--owen-owner@example.com", "ownerEmailAddrVerified":true }' // The response would be: // { "newSite": { "id": 1234, "origin": "comments-site-12345.base-domain.com" } }
That'll create a blog comments site with the local hostname:
comments-site-12345
, the full hostname would be:
comments-site-12345.base-domain.com
if in
/opt/talkyard/conf/play-framework.conf
you have configured:talkyard.baseDomain="base-domain.com" talkyard.createSiteApiSecret="CREATE_SITE_API_SECRET"
And the Authorization header value should be: "
Basic BASE64_USER_PWD
"
whereBASE64_USER_PWD
is this: "createsite:CREATE_SITE_API_SECRET
" base64 encoded (that is, the Basic Auth username must be "createsite").A blog with address
https://your-blog.example.com
would be allowed to embed the comments.Currently a site owner email address is required: When visiting the site for the first time, the site owner needs to click the Did you forget your password? link in the login dialog, and can then type his/her email — and if it's the correct address (i.e. the
ownerEmailAddr
) s/he will get a password reset email.***
If you want a discussion forum, instead of blog comments — then,
replacecreateEmbeddedComments: true
with:createForum: true
,and remove
embeddingSiteAddress
.***
End-to-end test, for creating an embedded comments site: https://github.com/debiki/talkyard/blob/35ec2078f1db48703eb0ab09fcac0077f4cc90f3/tests/e2e-wdio7/specs/embcom.create-site-via-api.2br.e2e.ts#L40
For creating a discussion forum: https://github.com/debiki/talkyard/blob/020271384df3ff20e0165551c264cebfcc64be0a/tests/e2e-wdio7/specs/dir.create-site-via-api.2br.e2e.ts#L42
The function that does the
/-/v0/create-site
API request: https://github.com/debiki/talkyard/blob/35ec2078f1db48703eb0ab09fcac0077f4cc90f3/tests/e2e-wdio7/utils/server.ts#L259***
It'd be interesting to hear about things you'd like to work differently :- ) — I'm guessing you aren't happy with precisely all details.
Maybe you'd like the site owner to get a magic URL with a one-time-login secret, so s/he didn't need to click Forgot Password, for example.
- Progresswith doing this idea