44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
const axios = require('axios')
|
|
const config = require('../config/index.js')
|
|
const baseURL = config.api_url
|
|
|
|
const apis = {}
|
|
module.exports = apis
|
|
|
|
apis.GetInstagramIDs = async () => {
|
|
try {
|
|
let result = await axios({
|
|
url: '/api/private/ig',
|
|
baseURL,
|
|
method: 'get',
|
|
headers: {
|
|
'X-Mtfos-Key': config.api_key
|
|
}
|
|
})
|
|
if (!('data' in result) || typeof result.data !== 'object' || !('list' in result.data) || !Array.isArray(result.data.list)) return null
|
|
return result.data.list
|
|
} catch (err) { return null }
|
|
}
|
|
|
|
apis.SendPostData = async (posts = []) => {
|
|
if (!Array.isArray(posts) || posts.length === 0) return
|
|
posts = posts.filter(t => {
|
|
return 'id' in t && 'post_id' in t && 'link' in t && 'text' in t
|
|
})
|
|
if (posts.length === 0) return
|
|
|
|
try {
|
|
await axios({
|
|
url: '/api/private/igposts',
|
|
baseURL,
|
|
method: 'post',
|
|
data: {
|
|
igs: posts
|
|
},
|
|
headers: {
|
|
'X-Mtfos-Key': config.api_key
|
|
}
|
|
})
|
|
} catch (err) { return null }
|
|
}
|