giphy support #1433
Answered
by
lizheming
Mister-Hope
asked this question in
Q&A
giphy support
#1433
-
Can we add support for giphy? Maybe adding a snippet for it in docs. Docs are at https://developers.giphy.com/, and users can apply key by themeselves ( and use our keys directly if possible) |
Beta Was this translation helpful? Give feedback.
Answered by
lizheming
Oct 2, 2022
Replies: 2 comments
-
This is a giphy search options example. How about we use giphy as default option instead of tenor? Waline.init({
search: (function({token, lang}) {
async function fetchGif(keyword, offset = 0) {
const baseUrl = 'https://api.giphy.com/v1/gifs/search';
const params = new URLSearchParams({
q: keyword,
api_key: token,
lang,
offset,
limit: 10,
rating: 'g',
});
const resp = await fetch(baseUrl + '?' + params.toString()).then(resp => resp.json());
return resp?.data?.map(({images, title}) => ({
title,
src: images.downsized_medium.url,
})) || [];
}
return {
async search(keyword) {
return fetchGif(keyword);
},
async more(keyword, count) {
return fetchGif(keyword, count);
}
};
})({token: '6CIMLkNMMOhRcXPoMCPkFy4Ybk2XUiMp', lang: 'zh-CN'}),
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Mister-Hope
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#1450