import messageCenter from '@/uilts/messageCenter/content'; import { getCookie } from '@/uilts/help' const TwitterApiCreateTweet = ({ info, data }) => { let params = { queryId: "hC1nuE-2d1NX5LYBuuAvtQ", features: { "dont_mention_me_view_api_enabled": true, "interactive_text_enabled": true, "responsive_web_uc_gql_enabled": false, "vibe_api_enabled": true, "responsive_web_edit_tweet_api_enabled": false, "standardized_nudges_misinfo": true, "responsive_web_enhance_cards_enabled": false }, variables: { "tweet_text": data.txt, "media": { "media_entities": [], "possibly_sensitive": false }, "withDownvotePerspective": true, "withReactionsMetadata": false, "withReactionsPerspective": false, "withSuperFollowsTweetFields": true, "withSuperFollowsUserFields": true, "semantic_annotation_ids": [], "dark_request": false } }; axios.post(`https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet`, params, { headers: { "accept": "*/*", "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA", "content-type": "application/json", "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "x-csrf-token": getCookie('ct0'), "x-twitter-active-user": "yes", "x-twitter-auth-type": "OAuth2Session", "x-twitter-client-language": "en" }, }).then(function (response) { messageCenter.send({ info, data: response }) }).catch(function (err) { messageCenter.send({ info, data: err }) }); } const TwitterLikeAPI = ({ info, data }) => { fetch("https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet", { "headers": { "accept": "*/*", "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA", "content-type": "application/json", "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "x-csrf-token": getCookie('ct0'), "x-twitter-active-user": "yes", "x-twitter-auth-type": "OAuth2Session", "x-twitter-client-language": "en" }, "referrer": "https://twitter.com/home", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"variables\":{\"tweet_id\":\"" + data.tweetId + "\"},\"queryId\":\"lI07N6Otwv1PhnEgXILM7A\"}", "method": "POST", "mode": "cors", "credentials": "include" }).then(() => { // 返回信息 messageCenter.send({ info, data: { task_done: true } }) }).catch(() => { messageCenter.send({ info, data: { task_done: false } }) }) } // const TwitterFollowAPI = ({ info, data }) => { // // // fetch("https://twitter.com/i/api/1.1/friendships/create.json", { // "headers": { // "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA", // "content-type": "application/x-www-form-urlencoded", // "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"", // "sec-ch-ua-mobile": "?0", // "sec-ch-ua-platform": "\"macOS\"", // "x-csrf-token": getCookie('ct0'), // "x-twitter-active-user": "yes", // "x-twitter-auth-type": "OAuth2Session", // "x-twitter-client-language": "zh-cn" // }, // "referrer": "https://twitter.com/home", // "referrerPolicy": "strict-origin-when-cross-origin", // "body": "include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&user_id=" + data.follow_name + "", // "method": "POST", // "mode": "cors", // "credentials": "include" // }).then(() => { // messageCenter.send({ info, data: { task_done: true, follow_name: data.follow_name } }) // }).catch(() => { // messageCenter.send({ info, data: { task_done: false, follow_name: data.follow_name } }) // }) // } const TwitterRetweetAPI = ({ info, data }) => { fetch("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet", { "headers": { "accept": "*/*", "accept-language": "zh,en;q=0.9,zh-CN;q=0.8", "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA", "content-type": "application/json", "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "x-csrf-token": getCookie('ct0'), "x-twitter-active-user": "yes", "x-twitter-auth-type": "OAuth2Session", "x-twitter-client-language": "zh-cn" }, "referrer": "https://twitter.com/home", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"variables\":{\"tweet_id\":\"" + data.tweetId + "\",\"dark_request\":false},\"queryId\":\"ojPdsZsimiJrUGLR1sjUtA\"}", "method": "POST", "mode": "cors", "credentials": "include" }).then(() => { messageCenter.send({ info, data: { task_done: true } }) }).catch(() => { messageCenter.send({ info, data: { task_done: false } }) }) } export default { TwitterApiCreateTweet, TwitterLikeAPI, TwitterRetweetAPI }