How to get Promoted Articles via API?
답변함
2022년 7월 05일에 게시됨
Is it possible to get a list of Promoted Articles via the API? I assumed there would be a filter/label in the Help Center Articles API but haven't found anything or I have missed it.
If its not possible currently, could it be added to the API?
0
6
댓글 6개
Ifra Saqlain
Hey Paul Hollands,
I have worked around it, why don't add label-name to your promoted articles via bulk feature:-
https://support.zendesk.com/hc/en-us/articles/4408835056154-Using-labels-on-your-help-center-articles#topic_jq3_lns_y2b
Then, you can get only promoted articles using label_name option via API. And then you can show articles using per_page option like 100 articles.
Thanks
0
Paul Hollands (Rare Website Team)
Hi Ifra Saqlain
Thanks for the alternative approach.
I'm not sure that approach would work however, due to the amount of articles we have would mean having to do multiple calls to List Articles API to get all articles to make sure we have all promoted articles as the API only returns max 100 articles at a time if I'm correct. Multiply that by the amount of end users accessing that data (as the end user might have different access rights) and that promoted Articles appears on multiple pages as a sidebar that would mean a lot of requests to the API and I'd be concerned we would hit a Rate Limit.
I could add caching my side to prevent multiple calls per set time but that seems like a lot of overhead managing the cache for a standard feature in the Help Center.
It feels to me that this should be possible as an option of the List Articles API - https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#options
or as a filter on Search Articles - https://developer.zendesk.com/api-reference/help_center/help-center-api/search/#search-articles
1
Ifra Saqlain
Hey Paul Hollands,
Remove previous script code which I mentioned above and add the given snippet:-
also, add the CSS to your style.css file:-
You already added the html element <div class="promoted-articles-list"></div> to your template where you want to show the articles:-
Output:-
0
Ifra Saqlain
Yes It's also possible. We can filter promoted articles via it's API without adding label_name.
I'll work around it and get back to you soon :)
1
Paul Hollands (Rare Website Team)
Hi Ifra Saqlain
Thanks for your reply.
That'll work as a workaround but was hoping to avoid our support team having to go through all the existing Promoted articles and adding a label to them.
Could a potential enhancement to the API be that ticking the "Promoted article" checkbox automatically creates a "promoted-article" label to filter on? Unless I'm missing something (I'm by no means an expert on the API), the "Promoted article" checkbox doesn't seem to have any use from API point of view.
0
Ifra Saqlain
Hey Paul Hollands,
Just follow the steps below:-
i). Create the article and add a label name and make that article promoted.
ii). Create more articles and give them same label-name.
iii). Copy the given code snippet and paste it to your script.js file.
iv). Copy the <ul class="promoted-articles-list"></ul> element and paste it to that template where you want to show the promoted article list.
I'm adding it on the homepage.
v). Make sure your document_head.hbs file must has jquery CDN.
API Taken From: https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/
Thanks
Team
0
댓글을 남기려면 로그인하세요.