doTask.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import messageCenter from '@/uilts/messageCenter/content';
  2. import { getCookie } from '@/uilts/help'
  3. const TwitterApiCreateTweet = ({ info, data }) => {
  4. let params = {
  5. queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
  6. features: {
  7. "dont_mention_me_view_api_enabled": true,
  8. "interactive_text_enabled": true,
  9. "responsive_web_uc_gql_enabled": false,
  10. "vibe_api_enabled": true,
  11. "responsive_web_edit_tweet_api_enabled": false,
  12. "standardized_nudges_misinfo": true,
  13. "responsive_web_enhance_cards_enabled": false
  14. },
  15. variables: {
  16. "tweet_text": data.txt,
  17. "media": {
  18. "media_entities": [],
  19. "possibly_sensitive": false
  20. },
  21. "withDownvotePerspective": true,
  22. "withReactionsMetadata": false,
  23. "withReactionsPerspective": false,
  24. "withSuperFollowsTweetFields": true,
  25. "withSuperFollowsUserFields": true,
  26. "semantic_annotation_ids": [],
  27. "dark_request": false
  28. }
  29. };
  30. axios.post(`https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet`,
  31. params, {
  32. headers: {
  33. "accept": "*/*",
  34. "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
  35. "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
  36. "content-type": "application/json",
  37. "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"",
  38. "sec-ch-ua-mobile": "?0",
  39. "sec-ch-ua-platform": "\"Windows\"",
  40. "sec-fetch-dest": "empty",
  41. "sec-fetch-mode": "cors",
  42. "sec-fetch-site": "same-origin",
  43. "x-csrf-token": getCookie('ct0'),
  44. "x-twitter-active-user": "yes",
  45. "x-twitter-auth-type": "OAuth2Session",
  46. "x-twitter-client-language": "en"
  47. },
  48. }).then(function (response) {
  49. messageCenter.send({ info, data: response })
  50. }).catch(function (err) {
  51. messageCenter.send({ info, data: err })
  52. });
  53. }
  54. const TwitterLikeAPI = ({ info, data }) => {
  55. fetch("https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet", {
  56. "headers": {
  57. "accept": "*/*",
  58. "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
  59. "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
  60. "content-type": "application/json",
  61. "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"",
  62. "sec-ch-ua-mobile": "?0",
  63. "sec-ch-ua-platform": "\"Windows\"",
  64. "sec-fetch-dest": "empty",
  65. "sec-fetch-mode": "cors",
  66. "sec-fetch-site": "same-origin",
  67. "x-csrf-token": getCookie('ct0'),
  68. "x-twitter-active-user": "yes",
  69. "x-twitter-auth-type": "OAuth2Session",
  70. "x-twitter-client-language": "en"
  71. },
  72. "referrer": "https://twitter.com/home",
  73. "referrerPolicy": "strict-origin-when-cross-origin",
  74. "body": "{\"variables\":{\"tweet_id\":\"" + data.tweetId + "\"},\"queryId\":\"lI07N6Otwv1PhnEgXILM7A\"}",
  75. "method": "POST",
  76. "mode": "cors",
  77. "credentials": "include"
  78. }).then(() => {
  79. // 返回信息
  80. messageCenter.send({ info, data: { task_done: true } })
  81. }).catch(() => {
  82. messageCenter.send({ info, data: { task_done: false } })
  83. })
  84. }
  85. // const TwitterFollowAPI = ({ info, data }) => {
  86. // //
  87. // fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
  88. // "headers": {
  89. // "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
  90. // "content-type": "application/x-www-form-urlencoded",
  91. // "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
  92. // "sec-ch-ua-mobile": "?0",
  93. // "sec-ch-ua-platform": "\"macOS\"",
  94. // "x-csrf-token": getCookie('ct0'),
  95. // "x-twitter-active-user": "yes",
  96. // "x-twitter-auth-type": "OAuth2Session",
  97. // "x-twitter-client-language": "zh-cn"
  98. // },
  99. // "referrer": "https://twitter.com/home",
  100. // "referrerPolicy": "strict-origin-when-cross-origin",
  101. // "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 + "",
  102. // "method": "POST",
  103. // "mode": "cors",
  104. // "credentials": "include"
  105. // }).then(() => {
  106. // messageCenter.send({ info, data: { task_done: true, follow_name: data.follow_name } })
  107. // }).catch(() => {
  108. // messageCenter.send({ info, data: { task_done: false, follow_name: data.follow_name } })
  109. // })
  110. // }
  111. const TwitterRetweetAPI = ({ info, data }) => {
  112. fetch("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet", {
  113. "headers": {
  114. "accept": "*/*",
  115. "accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
  116. "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
  117. "content-type": "application/json",
  118. "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
  119. "sec-ch-ua-mobile": "?0",
  120. "sec-ch-ua-platform": "\"macOS\"",
  121. "sec-fetch-dest": "empty",
  122. "sec-fetch-mode": "cors",
  123. "sec-fetch-site": "same-origin",
  124. "x-csrf-token": getCookie('ct0'),
  125. "x-twitter-active-user": "yes",
  126. "x-twitter-auth-type": "OAuth2Session",
  127. "x-twitter-client-language": "zh-cn"
  128. },
  129. "referrer": "https://twitter.com/home",
  130. "referrerPolicy": "strict-origin-when-cross-origin",
  131. "body": "{\"variables\":{\"tweet_id\":\"" + data.tweetId + "\",\"dark_request\":false},\"queryId\":\"ojPdsZsimiJrUGLR1sjUtA\"}",
  132. "method": "POST",
  133. "mode": "cors",
  134. "credentials": "include"
  135. }).then(() => {
  136. messageCenter.send({ info, data: { task_done: true } })
  137. }).catch(() => {
  138. messageCenter.send({ info, data: { task_done: false } })
  139. })
  140. }
  141. export default {
  142. TwitterApiCreateTweet,
  143. TwitterLikeAPI,
  144. TwitterRetweetAPI
  145. }