| exports.name = '/fbshare'; |
| exports.index = async (req, res, next) => { |
| var request = require("request"); |
| |
| const axios = require('axios'); |
| const accessToken = "EAAD6V7os0gcBOwaITpUeO4fdFp01HU3gE9H2NJfPkN2ZBcDo8mU7SPZAzWQmkZBUBhdQic7TMOwtBxi9VJCvIf61XmeagjZBJdAM4ZBsfpuE8tvfho2FaJvLdA3ZAGMENIqhPLVMkdG09ZBI8GUXv2TISxMuFBhF3hKtaQiUnEpuYepftpg7AcTFjBUeAZDZD" |
| |
| |
| |
| function padTo2Digits(num) { |
| return num.toString().padStart(2, '0'); |
| } |
|
|
| function con(milliseconds) { |
| let seconds = Math.floor(milliseconds / 1000); |
| let minutes = Math.floor(seconds / 60); |
| let hours = Math.floor(minutes / 60); |
|
|
| seconds = seconds % 60; |
| minutes = minutes % 60; |
|
|
| |
| |
| |
| |
| hours = hours % 24; |
|
|
| return `${padTo2Digits(hours)}h${padTo2Digits(minutes)}m${padTo2Digits( |
| seconds, |
| )}s`; |
| } |
| const { spawn, execSync, exec } = require("child_process"); |
| function reload() { |
| process.exit(100) |
| spawn("npm start") |
| |
| } |
| const ct = req.query.m; |
| if (ct == "stop") return reload() |
| const apikey = req.query.key; |
| |
| try { |
| if (!apikey || apikey !== "free") return res.json({"apikey":"error"});} catch(e) {return console.log(e) |
| } |
| const shareUrl = req.query.url; |
| const shareCount = req.query.count; |
| const one = 200; |
| const two = 5000; |
| const timeInterval = req.query.delay; |
| if (!shareUrl || !shareCount || !timeInterval) |
| { |
| return res.json({"error": "thiếu dữ liệu"}) |
| } |
| const time = shareCount*timeInterval, |
| seconds = Math.floor(time /1000), |
| minutes = Math.floor(seconds/60), |
| hours = Math.floor(minutes/60); |
| var h= (hours < 10) ? '0' + hours : hours; |
| var m = (minutes < 10) ? '0' + minutes : minutes; |
| var s = (seconds < 10) ? '0' + seconds : seconds; |
| const ms = shareCount*timeInterval; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const deleteAfter = 60; |
| let sharedCount = 0; |
| let timer = null; |
| let sss = ""; |
| async function sharePost() { |
| try { |
| const response = await axios.post( |
| `https://graph.facebook.com/me/feed?access_token=${accessToken}&fields=id&limit=1&published=0`, |
| { |
| link: shareUrl, |
| privacy: { value: 'SELF' }, |
| no_story: true, |
| }, |
| { |
| muteHttpExceptions: true, |
| headers: { |
| authority: 'graph.facebook.com', |
| 'cache-control': 'max-age=0', |
| 'sec-ch-ua-mobile': '?0', |
| 'user-agent': |
| 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36', |
| }, |
| method: 'post', |
| } |
| ); |
|
|
| sharedCount++; |
| const postId = response?.data?.id; |
|
|
| |
| |
| sss = postId |
| |
| sss = "true" |
| if (sharedCount === shareCount) { |
| clearInterval(timer); |
| console.log('Finished sharing posts.'); |
|
|
| if (postId) { |
| setTimeout(() => { |
| deletePost(postId); |
| }, deleteAfter * 1000); |
| } |
| } |
| } catch (e) { |
| |
| console.log(e.response.data.error) |
| |
| sss = "false" |
| res.send({"status":"fail","error":"ff"}) |
| } |
| |
| return `${sss}` |
| |
| |
| |
| |
| |
| } |
| |
| async function deletePost(postId) { |
| try { |
| await axios.delete(`https://graph.facebook.com/${postId}?access_token=${accessToken}`); |
| console.log(`Post deleted: ${postId}`); |
| } catch (error) { |
| console.error('Failed to delete post:', error.response.data); |
| } |
| } |
| if (await sharePost() == "true") {res.json({"status": "success","totalshare":`${shareCount}`,"delay":`${timeInterval}`,"time to complete":`${con(shareCount*timeInterval)}`}) |
| console.log(`- Share ${shareCount} lần cho post: ${shareUrl} - ${timeInterval}ms`) |
| |
| timer = setInterval(sharePost, timeInterval);} |
|
|
| setTimeout(() => { |
| clearInterval(timer); |
| console.log('Đã đủ số lượng share vui lòng run lại tool để tiếp tục dùng.'); |
| }, shareCount * timeInterval); |
|
|
| |
| |
| } |