@pipedream/twitter 0.3.11 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -71
- package/dist/actions/add-user-to-list/add-user-to-list.d.ts +194 -0
- package/dist/actions/add-user-to-list/add-user-to-list.mjs +44 -0
- package/dist/actions/create-tweet/create-tweet.d.ts +101 -0
- package/dist/actions/create-tweet/create-tweet.mjs +78 -0
- package/dist/actions/delete-tweet/delete-tweet.d.ts +128 -0
- package/dist/actions/delete-tweet/delete-tweet.mjs +29 -0
- package/dist/actions/follow-user/follow-user.d.ts +131 -0
- package/dist/actions/follow-user/follow-user.mjs +37 -0
- package/dist/actions/get-tweet/get-tweet.d.ts +132 -0
- package/dist/actions/get-tweet/get-tweet.mjs +34 -0
- package/dist/actions/get-user/get-user.d.ts +133 -0
- package/dist/actions/get-user/get-user.mjs +40 -0
- package/dist/actions/like-tweet/like-tweet.d.ts +128 -0
- package/dist/actions/like-tweet/like-tweet.mjs +31 -0
- package/dist/actions/list-favorites/list-favorites.d.ts +202 -0
- package/dist/actions/list-favorites/list-favorites.mjs +50 -0
- package/dist/actions/list-followers/list-followers.d.ts +202 -0
- package/dist/actions/list-followers/list-followers.mjs +50 -0
- package/dist/actions/list-lists/list-lists.d.ts +200 -0
- package/dist/actions/list-lists/list-lists.mjs +50 -0
- package/dist/actions/list-mentions/list-mentions.d.ts +200 -0
- package/dist/actions/list-mentions/list-mentions.mjs +50 -0
- package/dist/actions/list-user-tweets/list-user-tweets.d.ts +202 -0
- package/dist/actions/list-user-tweets/list-user-tweets.mjs +50 -0
- package/dist/actions/retweet/retweet.d.ts +128 -0
- package/dist/actions/retweet/retweet.mjs +34 -0
- package/dist/actions/simple-search/simple-search.d.ts +201 -0
- package/dist/actions/simple-search/simple-search.mjs +50 -0
- package/dist/actions/simple-search-in-list/simple-search-in-list.d.ts +206 -0
- package/dist/actions/simple-search-in-list/simple-search-in-list.mjs +58 -0
- package/dist/actions/unfollow-user/unfollow-user.d.ts +131 -0
- package/dist/actions/unfollow-user/unfollow-user.mjs +33 -0
- package/dist/actions/unlike-tweet/unlike-tweet.d.ts +128 -0
- package/dist/actions/unlike-tweet/unlike-tweet.mjs +29 -0
- package/dist/app/twitter.app.d.ts +65 -0
- package/dist/app/twitter.app.mjs +291 -0
- package/dist/common/additionalProps.d.ts +0 -0
- package/dist/common/additionalProps.mjs +138 -0
- package/dist/common/dataFields.d.ts +6 -0
- package/dist/common/dataFields.mjs +80 -0
- package/dist/common/expansions.d.ts +3 -0
- package/dist/common/expansions.mjs +17 -0
- package/dist/common/methods.d.ts +20 -0
- package/dist/common/methods.mjs +69 -0
- package/dist/common/types/fields.d.ts +18 -0
- package/dist/common/types/fields.mjs +1 -0
- package/dist/common/types/requestParams.d.ts +105 -0
- package/dist/common/types/requestParams.mjs +1 -0
- package/dist/common/types/responseSchemas.d.ts +42 -0
- package/dist/common/types/responseSchemas.mjs +1 -0
- package/dist/sources/common/base.d.ts +87 -0
- package/dist/sources/common/base.mjs +60 -0
- package/dist/sources/common/cacheUserId.d.ts +7 -0
- package/dist/sources/common/cacheUserId.mjs +18 -0
- package/dist/sources/common/getItemSummary.d.ts +4 -0
- package/dist/sources/common/getItemSummary.mjs +12 -0
- package/dist/sources/new-follower-of-user/new-follower-of-user.d.ts +149 -0
- package/dist/sources/new-follower-of-user/new-follower-of-user.mjs +45 -0
- package/dist/sources/new-list-followed/new-list-followed.d.ts +149 -0
- package/dist/sources/new-list-followed/new-list-followed.mjs +46 -0
- package/dist/sources/new-tweet-in-list/new-tweet-in-list.d.ts +147 -0
- package/dist/sources/new-tweet-in-list/new-tweet-in-list.mjs +42 -0
- package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.d.ts +149 -0
- package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.mjs +45 -0
- package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.d.ts +149 -0
- package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.mjs +45 -0
- package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.d.ts +147 -0
- package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.mjs +44 -0
- package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.d.ts +149 -0
- package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +75 -0
- package/dist/sources/new-user-followed/new-user-followed.d.ts +148 -0
- package/dist/sources/new-user-followed/new-user-followed.mjs +46 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +10 -14
- package/actions/add-user-to-list/add-user-to-list.mjs +0 -62
- package/actions/advanced-search/advanced-search.mjs +0 -113
- package/actions/common.mjs +0 -29
- package/actions/create-tweet/create-tweet.mjs +0 -146
- package/actions/delete-tweet/delete-tweet.mjs +0 -42
- package/actions/follow-user/follow-user.mjs +0 -48
- package/actions/get-tweet/get-tweet.mjs +0 -42
- package/actions/get-user/get-user.mjs +0 -50
- package/actions/like-tweet/like-tweet.mjs +0 -42
- package/actions/list-favorites/list-favorites.mjs +0 -63
- package/actions/list-followers/list-followers.mjs +0 -67
- package/actions/list-lists/list-lists.mjs +0 -69
- package/actions/list-mentions/list-mentions.mjs +0 -55
- package/actions/list-pending-followers/list-pending-followers.mjs +0 -32
- package/actions/list-retweets/list-retweets.mjs +0 -54
- package/actions/list-user-tweets/list-user-tweets.mjs +0 -80
- package/actions/retweet/retweet.mjs +0 -27
- package/actions/simple-search/simple-search.mjs +0 -62
- package/actions/simple-search-in-list/simple-search-in-list.mjs +0 -48
- package/actions/unfollow-user/unfollow-user.mjs +0 -48
- package/actions/unlike-tweet/unlike-tweet.mjs +0 -40
- package/actions/upload-media/upload-media.mjs +0 -122
- package/old.md +0 -169
- package/sources/common/followed.mjs +0 -38
- package/sources/common/followers.mjs +0 -159
- package/sources/common/tweets.mjs +0 -155
- package/sources/language-codes.mjs +0 -742
- package/sources/my-liked-tweets/my-liked-tweets.mjs +0 -30
- package/sources/my-tweets/my-tweets.mjs +0 -48
- package/sources/new-follower-of-me/new-follower-of-me.mjs +0 -69
- package/sources/new-follower-of-user/new-follower-of-user.mjs +0 -25
- package/sources/new-list-followed/new-list-followed.mjs +0 -24
- package/sources/new-trends-by-geo/new-trends-by-geo.mjs +0 -40
- package/sources/new-tweet-in-list/new-tweet-in-list.mjs +0 -49
- package/sources/new-unfollower-of-me/new-unfollower-of-me.mjs +0 -16
- package/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +0 -25
- package/sources/new-user-followed/new-user-followed.mjs +0 -25
- package/sources/search-mentions/search-mentions.mjs +0 -144
- package/sources/tweets-liked-by-user/tweets-liked-by-user.mjs +0 -38
- package/sources/user-tweets/user-tweets.mjs +0 -49
- package/sources/watch-retweets-of-me/watch-retweets-of-me.mjs +0 -36
- package/sources/watch-retweets-of-my-tweet/watch-retweets-of-my-tweet.mjs +0 -44
- package/sources/watch-retweets-of-user-tweet/watch-retweets-of-user-tweet.mjs +0 -34
- package/twitter.app.mjs +0 -1161
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "twitter-list-retweets",
|
|
6
|
-
name: "List Retweets",
|
|
7
|
-
description: "Return a collection of recent retweets of a tweet by ID parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweets-id)",
|
|
8
|
-
version: "0.0.2",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
id: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.twitter,
|
|
15
|
-
"tweetID",
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
count: {
|
|
19
|
-
propDefinition: [
|
|
20
|
-
common.props.twitter,
|
|
21
|
-
"count",
|
|
22
|
-
],
|
|
23
|
-
optional: true,
|
|
24
|
-
default: 20,
|
|
25
|
-
},
|
|
26
|
-
maxRequests: {
|
|
27
|
-
propDefinition: [
|
|
28
|
-
common.props.twitter,
|
|
29
|
-
"maxRequests",
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
async run({ $ }) {
|
|
34
|
-
const {
|
|
35
|
-
id,
|
|
36
|
-
count,
|
|
37
|
-
maxRequests,
|
|
38
|
-
} = this;
|
|
39
|
-
|
|
40
|
-
const params = {
|
|
41
|
-
$,
|
|
42
|
-
id,
|
|
43
|
-
count,
|
|
44
|
-
maxRequests,
|
|
45
|
-
};
|
|
46
|
-
const tweets = await this.paginate(this.twitter.getRetweets.bind(this), params);
|
|
47
|
-
const results = [];
|
|
48
|
-
for await (const tweet of tweets) {
|
|
49
|
-
results.push(tweet);
|
|
50
|
-
}
|
|
51
|
-
$.export("$summary", "Successfully retrieved retweets");
|
|
52
|
-
return results;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
...common,
|
|
5
|
-
key: "twitter-list-user-tweets",
|
|
6
|
-
name: "List User Tweets",
|
|
7
|
-
description: "Return a collection of the most recent tweets posted by a user. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline)",
|
|
8
|
-
version: "0.0.2",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
...common.props,
|
|
12
|
-
screenName: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
common.props.twitter,
|
|
15
|
-
"screenName",
|
|
16
|
-
],
|
|
17
|
-
optional: true,
|
|
18
|
-
},
|
|
19
|
-
count: {
|
|
20
|
-
propDefinition: [
|
|
21
|
-
common.props.twitter,
|
|
22
|
-
"count",
|
|
23
|
-
],
|
|
24
|
-
optional: true,
|
|
25
|
-
default: 20,
|
|
26
|
-
},
|
|
27
|
-
maxRequests: {
|
|
28
|
-
propDefinition: [
|
|
29
|
-
common.props.twitter,
|
|
30
|
-
"maxRequests",
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
includeRetweets: {
|
|
34
|
-
propDefinition: [
|
|
35
|
-
common.props.twitter,
|
|
36
|
-
"includeRetweets",
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
includeReplies: {
|
|
40
|
-
propDefinition: [
|
|
41
|
-
common.props.twitter,
|
|
42
|
-
"includeReplies",
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
methods: {
|
|
47
|
-
...common.methods,
|
|
48
|
-
shouldExcludeReplies(includeReplies) {
|
|
49
|
-
return includeReplies === "exclude";
|
|
50
|
-
},
|
|
51
|
-
shouldIncludeRetweets(includeRetweets) {
|
|
52
|
-
return includeRetweets !== "exclude";
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
async run({ $ }) {
|
|
56
|
-
const {
|
|
57
|
-
screenName,
|
|
58
|
-
count,
|
|
59
|
-
maxRequests,
|
|
60
|
-
includeRetweets,
|
|
61
|
-
includeReplies,
|
|
62
|
-
} = this;
|
|
63
|
-
|
|
64
|
-
const params = {
|
|
65
|
-
$,
|
|
66
|
-
screenName,
|
|
67
|
-
count,
|
|
68
|
-
maxRequests,
|
|
69
|
-
exclude_replies: this.shouldExcludeReplies(includeReplies),
|
|
70
|
-
include_rts: this.shouldIncludeRetweets(includeRetweets),
|
|
71
|
-
};
|
|
72
|
-
const tweets = await this.paginate(this.twitter.getUserTimeline.bind(this), params);
|
|
73
|
-
const results = [];
|
|
74
|
-
for await (const tweet of tweets) {
|
|
75
|
-
results.push(tweet);
|
|
76
|
-
}
|
|
77
|
-
$.export("$summary", "Successfully retrieved user tweets");
|
|
78
|
-
return results;
|
|
79
|
-
},
|
|
80
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
key: "twitter-retweet",
|
|
5
|
-
name: "Retweet a tweet",
|
|
6
|
-
description: "Retweets a specific tweet by ID. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id)",
|
|
7
|
-
version: "0.0.3",
|
|
8
|
-
type: "action",
|
|
9
|
-
props: {
|
|
10
|
-
twitter,
|
|
11
|
-
tweetID: {
|
|
12
|
-
propDefinition: [
|
|
13
|
-
twitter,
|
|
14
|
-
"tweetID",
|
|
15
|
-
],
|
|
16
|
-
description: "The numerical ID of the tweet you'd like to retweet",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
async run({ $ }) {
|
|
20
|
-
const res = await this.twitter.retweet({
|
|
21
|
-
$,
|
|
22
|
-
tweetID: this.tweetID,
|
|
23
|
-
});
|
|
24
|
-
$.export("$summary", "Tweet successfully retweeted");
|
|
25
|
-
return res;
|
|
26
|
-
},
|
|
27
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
key: "twitter-simple-search",
|
|
5
|
-
name: "Simple Search",
|
|
6
|
-
description: "Return Tweets that matches your search criteria. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets)",
|
|
7
|
-
version: "0.0.8",
|
|
8
|
-
type: "action",
|
|
9
|
-
props: {
|
|
10
|
-
twitter,
|
|
11
|
-
q: {
|
|
12
|
-
propDefinition: [
|
|
13
|
-
twitter,
|
|
14
|
-
"q",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
resultType: {
|
|
18
|
-
propDefinition: [
|
|
19
|
-
twitter,
|
|
20
|
-
"resultType",
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
includeRetweets: {
|
|
24
|
-
propDefinition: [
|
|
25
|
-
twitter,
|
|
26
|
-
"includeRetweets",
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
includeReplies: {
|
|
30
|
-
propDefinition: [
|
|
31
|
-
twitter,
|
|
32
|
-
"includeReplies",
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
async run({ $ }) {
|
|
37
|
-
const {
|
|
38
|
-
resultType,
|
|
39
|
-
enrichTweets,
|
|
40
|
-
includeReplies,
|
|
41
|
-
includeRetweets,
|
|
42
|
-
maxRequests,
|
|
43
|
-
count,
|
|
44
|
-
} = this;
|
|
45
|
-
let q = this.q;
|
|
46
|
-
|
|
47
|
-
// run paginated search
|
|
48
|
-
const res = await this.twitter.paginatedSearch({
|
|
49
|
-
$,
|
|
50
|
-
q,
|
|
51
|
-
resultType,
|
|
52
|
-
enrichTweets,
|
|
53
|
-
includeReplies,
|
|
54
|
-
includeRetweets,
|
|
55
|
-
maxRequests,
|
|
56
|
-
count,
|
|
57
|
-
limitFirstPage: false,
|
|
58
|
-
});
|
|
59
|
-
$.export("$summary", "Search completed successfully");
|
|
60
|
-
return res;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
key: "twitter-simple-search-in-list",
|
|
5
|
-
name: "Simple Search in List",
|
|
6
|
-
description: "Return Tweets that match your search criteria in a specific list. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-statuses)",
|
|
7
|
-
version: "0.0.2",
|
|
8
|
-
type: "action",
|
|
9
|
-
props: {
|
|
10
|
-
twitter,
|
|
11
|
-
listId: {
|
|
12
|
-
propDefinition: [
|
|
13
|
-
twitter,
|
|
14
|
-
"list",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
query: {
|
|
18
|
-
propDefinition: [
|
|
19
|
-
twitter,
|
|
20
|
-
"q",
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
includeRetweets: {
|
|
24
|
-
propDefinition: [
|
|
25
|
-
twitter,
|
|
26
|
-
"includeRetweets",
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
includeEntities: {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
label: "Entities",
|
|
32
|
-
description: "Include the 'entities' node, which offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags",
|
|
33
|
-
default: false,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
async run({ $ }) {
|
|
37
|
-
let tweets = await this.twitter.getPaginateListTweets({
|
|
38
|
-
listId: this.listId,
|
|
39
|
-
includeEntities: this.includeEntities,
|
|
40
|
-
includeRetweets: this.includeRetweets !== "exclude",
|
|
41
|
-
});
|
|
42
|
-
tweets = tweets.filter((tweet) => tweet?.full_text?.includes(this.query));
|
|
43
|
-
$.export("$summary", `${tweets.length} search ${tweets.length === 1
|
|
44
|
-
? "result has"
|
|
45
|
-
: "results have"} been found.`);
|
|
46
|
-
return tweets;
|
|
47
|
-
},
|
|
48
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
key: "twitter-unfollow-user",
|
|
6
|
-
name: "Unfollow User",
|
|
7
|
-
description: "Unfollow the user specified by ID or screen name parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy)",
|
|
8
|
-
version: "0.0.2",
|
|
9
|
-
type: "action",
|
|
10
|
-
props: {
|
|
11
|
-
twitter,
|
|
12
|
-
userId: {
|
|
13
|
-
propDefinition: [
|
|
14
|
-
twitter,
|
|
15
|
-
"userId",
|
|
16
|
-
],
|
|
17
|
-
optional: true,
|
|
18
|
-
},
|
|
19
|
-
screenName: {
|
|
20
|
-
propDefinition: [
|
|
21
|
-
twitter,
|
|
22
|
-
"screenName",
|
|
23
|
-
],
|
|
24
|
-
optional: true,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
async run({ $ }) {
|
|
28
|
-
const {
|
|
29
|
-
userId,
|
|
30
|
-
screenName,
|
|
31
|
-
} = this;
|
|
32
|
-
|
|
33
|
-
if (!userId && !screenName) {
|
|
34
|
-
throw new ConfigurationError("This action requires either User ID or Screen Name. Please enter one or the other above.");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const params = {
|
|
38
|
-
user_id: userId,
|
|
39
|
-
screen_name: screenName,
|
|
40
|
-
};
|
|
41
|
-
const response = await this.twitter.unfollowUser({
|
|
42
|
-
params,
|
|
43
|
-
$,
|
|
44
|
-
});
|
|
45
|
-
$.export("$summary", "Successfully unfollowed user");
|
|
46
|
-
return response;
|
|
47
|
-
},
|
|
48
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
key: "twitter-unlike-tweet",
|
|
5
|
-
name: "Unike Tweet",
|
|
6
|
-
description: "Unike the tweet specified specified in the ID parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy)",
|
|
7
|
-
version: "0.0.2",
|
|
8
|
-
type: "action",
|
|
9
|
-
props: {
|
|
10
|
-
twitter,
|
|
11
|
-
id: {
|
|
12
|
-
propDefinition: [
|
|
13
|
-
twitter,
|
|
14
|
-
"tweetID",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
includeEntities: {
|
|
18
|
-
propDefinition: [
|
|
19
|
-
twitter,
|
|
20
|
-
"includeEntities",
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
async run({ $ }) {
|
|
25
|
-
const {
|
|
26
|
-
id,
|
|
27
|
-
includeEntities,
|
|
28
|
-
} = this;
|
|
29
|
-
|
|
30
|
-
const params = {
|
|
31
|
-
$,
|
|
32
|
-
id,
|
|
33
|
-
includeEntities,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const res = this.twitter.unlikeTweet(params);
|
|
37
|
-
$.export("$summary", "Successfully unliked tweet");
|
|
38
|
-
return res;
|
|
39
|
-
},
|
|
40
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import twitter from "../../twitter.app.mjs";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import mime from "mime";
|
|
4
|
-
import FormData from "form-data";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
key: "twitter-upload-media",
|
|
8
|
-
name: "Upload Media",
|
|
9
|
-
description: "Upload images or other media types to Twitter. Returns a `media_id_string` to be used with the Create Tweet action. [See the docs here](https://developer.twitter.com/en/docs/tutorials/uploading-media)",
|
|
10
|
-
version: "0.0.3",
|
|
11
|
-
type: "action",
|
|
12
|
-
props: {
|
|
13
|
-
twitter,
|
|
14
|
-
file: {
|
|
15
|
-
type: "string",
|
|
16
|
-
label: "File",
|
|
17
|
-
description: "The file to upload to Twitter, please provide a file from `/tmp`. To upload a file to `/tmp` folder, please follow the doc [here](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
|
|
18
|
-
},
|
|
19
|
-
mediaType: {
|
|
20
|
-
type: "string",
|
|
21
|
-
label: "Media Type",
|
|
22
|
-
description: "The MIME type of the media being uploaded",
|
|
23
|
-
options() {
|
|
24
|
-
return Object.values(mime._types);
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
mediaCategory: {
|
|
28
|
-
type: "string",
|
|
29
|
-
label: "Media Category",
|
|
30
|
-
description: "The category that represents how the media will be used",
|
|
31
|
-
options: [
|
|
32
|
-
"amplify_video",
|
|
33
|
-
"tweet_gif",
|
|
34
|
-
"tweet_image",
|
|
35
|
-
"tweet_video",
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
async append($, fileSize, mediaId) {
|
|
41
|
-
const bufferLength = 1000000;
|
|
42
|
-
const theBuffer = new Buffer(bufferLength);
|
|
43
|
-
let offset = 0;
|
|
44
|
-
let segment = 0;
|
|
45
|
-
const fd = fs.openSync(this.file, "r");
|
|
46
|
-
while (offset < fileSize) {
|
|
47
|
-
const bytesRead = fs.readSync(fd, theBuffer, 0, bufferLength, null);
|
|
48
|
-
const mediaData = bytesRead < bufferLength
|
|
49
|
-
? theBuffer.slice(0, bytesRead)
|
|
50
|
-
: theBuffer;
|
|
51
|
-
const data = new FormData();
|
|
52
|
-
data.append("command", "APPEND");
|
|
53
|
-
data.append("media_id", mediaId);
|
|
54
|
-
data.append("media_data", mediaData.toString("base64"));
|
|
55
|
-
data.append("segment_index", segment);
|
|
56
|
-
await this.twitter.uploadMedia({
|
|
57
|
-
data,
|
|
58
|
-
headers: {
|
|
59
|
-
"Content-Type": `multipart/form-data; boundary=${data._boundary}`,
|
|
60
|
-
},
|
|
61
|
-
$,
|
|
62
|
-
});
|
|
63
|
-
segment++;
|
|
64
|
-
offset += bufferLength;
|
|
65
|
-
}
|
|
66
|
-
fs.close(fd);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
async run({ $ }) {
|
|
70
|
-
// INIT
|
|
71
|
-
const fileSize = (fs.statSync(this.file)).size;
|
|
72
|
-
const params = {
|
|
73
|
-
command: "INIT",
|
|
74
|
-
total_bytes: fileSize,
|
|
75
|
-
media_type: this.mediaType,
|
|
76
|
-
additional_owners: this.twitter.$auth.oauth_uid,
|
|
77
|
-
};
|
|
78
|
-
if (this.mediaCategory) {
|
|
79
|
-
params.media_category = this.mediaCategory;
|
|
80
|
-
}
|
|
81
|
-
const { media_id_string: mediaId } = await this.twitter.uploadMedia({
|
|
82
|
-
params,
|
|
83
|
-
$,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// APPEND
|
|
87
|
-
await this.append($, fileSize, mediaId);
|
|
88
|
-
|
|
89
|
-
// FINALIZE
|
|
90
|
-
let response;
|
|
91
|
-
response = await this.twitter.uploadMedia({
|
|
92
|
-
params: {
|
|
93
|
-
command: "FINALIZE",
|
|
94
|
-
media_id: mediaId,
|
|
95
|
-
},
|
|
96
|
-
$,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// STATUS
|
|
100
|
-
while (this.mediaCategory?.includes("video")) {
|
|
101
|
-
response = await this.twitter.uploadMedia({
|
|
102
|
-
params: {
|
|
103
|
-
command: "STATUS",
|
|
104
|
-
media_id: mediaId,
|
|
105
|
-
},
|
|
106
|
-
method: "GET",
|
|
107
|
-
$,
|
|
108
|
-
});
|
|
109
|
-
const { processing_info: info } = response;
|
|
110
|
-
if (info?.error) {
|
|
111
|
-
throw new Error(JSON.stringify(info.error));
|
|
112
|
-
}
|
|
113
|
-
if (info?.state === "succeeded") {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
setTimeout(() => {}, info.check_after_secs * 1000);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
response && $.export("$summary", `Successfully uploaded media with Media ID ${mediaId}`);
|
|
120
|
-
return response;
|
|
121
|
-
},
|
|
122
|
-
};
|
package/old.md
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
|
|
3
|
-
<img width="124" height="100" src="/images/twitter/TwitterLogo.png">
|
|
4
|
-
</p>
|
|
5
|
-
<h1 align="center"><strong>Twitter Workflow Automation</strong></h1>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<p align="center">Patterns for processing streams of tweets and interacting with the Twitter API</p>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="#example-workflows"><img width="30%" src="/images/twitter/ExampleWorkflow.png" alt="Getting Started"></a>
|
|
12
|
-
<a href="#twitter-event-sources"><img width="30%" src="/images/twitter/TwitterEventSources.png" alt="Example Worksflows"></a>
|
|
13
|
-
<a href="#sse-and-rest-apis"><img width="30%" src="/images/twitter/SSE_RESTAPI.png" alt="SSE + REST API"></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Example Workflows
|
|
19
|
-
Workflows are linear sequences of steps — just Node.js code —hosted and run by Pipedream.
|
|
20
|
-
|
|
21
|
-
**You can copy the workflows below and run them in your Pipedream account** [**for free**](https://docs.pipedream.com/pricing/ ). They run code on new tweets and interact with the Twitter API in creative ways. You can modify or extend them in any way you'd like, [**running your own Node code**](https://docs.pipedream.com/workflows/steps/code/) or using [**pre-built functions**](https://docs.pipedream.com/workflows/steps/actions/) to connect to [**200+ integrated apps**](https://docs.pipedream.com/apps/all-apps/).
|
|
22
|
-
|
|
23
|
-
On copy, you'll be asked to create a [**Twitter event source**](#twitter-event-sources) that triggers your workflow on new tweets matching your target search.
|
|
24
|
-
|
|
25
|
-
A single Twitter source can trigger multiple workflows. If you already created a source you want to use as a trigger, click **Select Another Trigger** near the bottom-left of the source selector.
|
|
26
|
-
|
|
27
|
-
<p align="center">
|
|
28
|
-
<a href="https://pipedream.com/@dylan/twitter-to-email-p_zACral/readme"><img alt="Twitter to Email" src="/images/twitter/T2Em.png" width="45%"></a>
|
|
29
|
-
<a href="https://pipedream.com/@dylan/send-an-http-post-request-on-new-tweets-p_6lCRoN/readme"><img alt="Twitter to Webhook" src="/images/twitter/T2We.png" width="45%"></a>
|
|
30
|
-
</p>
|
|
31
|
-
<p align="center">
|
|
32
|
-
<a href="https://pipedream.com/@dylan/twitter-to-aws-sqs-p_vQCraZ/readme"><img alt="Twitter to AWS SQS" src="/images/twitter/T2AS.png" width="45%"></a>
|
|
33
|
-
<a href="https://pipedream.com/@dylan/twitter-to-aws-eventbridge-event-bus-p_ZJCWpg/readme"><img alt="Twitter to AWS EventBridge" src="/images/twitter/T2AE.png" width="45%"></a>
|
|
34
|
-
</p>
|
|
35
|
-
<p align="center">
|
|
36
|
-
<a href="https://pipedream.com/@dylan/twitter-to-aws-lambda-p_wOCAdP/readme"><img alt="Twitter to AWS Lambda" src="/images/twitter/T2AL.png" width="45%"></a>
|
|
37
|
-
<a href="https://pipedream.com/@dylan/twitter-to-telegram-p_QPC8JP/readme"><img alt="Twitter to Telegram" src="/images/twitter/T2Te.png" width="45%"></a>
|
|
38
|
-
</p>
|
|
39
|
-
<p align="center">
|
|
40
|
-
<a href="https://pipedream.com/@pravin/twitter-mentions-slack-p_dDCA5e/edit"><img alt="Twitter to Slack" src="/images/twitter/T2Sl.png" width="45%"></a>
|
|
41
|
-
<a href="https://pipedream.com/@dylan/twitter-to-discord-p_MOCQ9Y/readme"><img alt="Twitter to Discord" src="/images/twitter/T2Ti.png" width="45%"></a>
|
|
42
|
-
</p>
|
|
43
|
-
<p align="center">
|
|
44
|
-
<a href="https://pipedream.com/@dylan/twitter-to-s3-p_KwCZGA/readme"><img alt="Twitter to S3" src="/images/twitter/T2S3.png" width="45%"></a>
|
|
45
|
-
<a href="https://pipedream.com/@dylan/twitter-to-pipedream-sql-service-p_brCMA9/readme"><img alt="Twitter to SQ:" src="/images/twitter/T2Sq.png" width="45%"></a>
|
|
46
|
-
</p>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Twitter Event Sources
|
|
51
|
-
|
|
52
|
-
Pipedream [**event sources**](https://docs.pipedream.com/event-sources/) emit Twitter events in real time: tweets, follows, likes, and more. Sources can trigger [**Pipedream workflows**](#example-workflows), and can be accessed via [**SSE or REST APIs**](#apis).
|
|
53
|
-
|
|
54
|
-
Click on a source below to get started.
|
|
55
|
-
|
|
56
|
-
<p align="center">
|
|
57
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fsearch-twitter.js&app=twitter"><img alt="Search Mention" src="/images/twitter/SM.png" width="45%"></a>
|
|
58
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fmy-tweets.js&app=twitter"><img alt="My Tweets" src="/images/twitter/MT.png" width="45%"></a>
|
|
59
|
-
</p>
|
|
60
|
-
<p align="center">
|
|
61
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fnew-follower-of-user.js&app=twitter"><img alt="New Follower for User" src="/images/twitter/NFfU.png" width="45%"></a>
|
|
62
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fnew-follower-of-me.js&app=twitter"><img alt="My New Followers" src="/images/twitter/MNF.png" width="45%"></a>
|
|
63
|
-
</p>
|
|
64
|
-
<p align="center">
|
|
65
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fmy-liked-tweets.js&app=twitter"><img alt="My Liked Tweets" src="/images/twitter/MLT.png" width="45%"></a>
|
|
66
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Ftweets-liked-by-user.js&app=twitter"><img alt="Tweets Liked by User" src="/images/twitter/TLbU.png" width="45%"></a>
|
|
67
|
-
</p>
|
|
68
|
-
<p align="center">
|
|
69
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fuser-tweets.js&app=twitter"><img alt="New Tweets from User" src="/images/twitter/NTfU.png" width="45%"></a>
|
|
70
|
-
<a href="https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fnew-trends-by-geo.js&app=twitter"><img alt="New Trends by Geo" src="/images/twitter/NTbG.png" width="45%"></a>
|
|
71
|
-
</p>
|
|
72
|
-
|
|
73
|
-
Let's see how sources work with an end-to-end example:**running code on new mentions**.
|
|
74
|
-
|
|
75
|
-
Most Twitter bots react to other tweets. For example, you might want to reply to a user with a specific message every time they mention you. Or you may want to store every tweet with a specific hashtag in an Amazon S3 bucket.
|
|
76
|
-
|
|
77
|
-
When you create a Twitter bot, you typically have to sign up for a Twitter developer account, create your own app, host it somewhere, and run code to poll for new tweets. This is a means to an end:**all you really want to do is run code on new tweets**.
|
|
78
|
-
|
|
79
|
-
```js
|
|
80
|
-
// Don't care how I get tweets
|
|
81
|
-
for (const tweet of tweets) {
|
|
82
|
-
// Just want to run code
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Pipedream lets you create a stream of tweets you can process programmatically in seconds, avoiding the app setup entirely. These are called [**event sources**](https://docs.pipedream.com/event-sources/).
|
|
87
|
-
|
|
88
|
-
Pipedream runs the code to poll for new tweets matching your search terms, emitting them as events you can run code on.
|
|
89
|
-
|
|
90
|
-
<p align="center">
|
|
91
|
-
<img alt="pipeDream" src="/images/twitter/TwitterPipeDream.png">
|
|
92
|
-
</p>
|
|
93
|
-
|
|
94
|
-
Then, you can immediately process those tweets in a few different ways:
|
|
95
|
-
|
|
96
|
-
+ Trigger a Pipedream workflow for each tweet, running hosted Node.js code in real time
|
|
97
|
-
+ Subscribe to a private SSE stream, which also publishes tweets in real time
|
|
98
|
-
+ Access tweets in batch using Pipedream's REST API
|
|
99
|
-
|
|
100
|
-
To get started, [**create a new Twitter search source in the Pipedream UI**](https://pipedream.com/sources?action=create&url=https%3A%2F%2Fgithub.com%2FPipedreamHQ%2Fpipedream%2Fblob%2Fmaster%2Fcomponents%2Ftwitter%2Fsearch-twitter.js&app=twitter&src=twitter.pipedream.com). Name the source, connect your Twitter account, and add your search term:
|
|
101
|
-
|
|
102
|
-
<p align="center">
|
|
103
|
-
<kbd><img alt="Twitter Source in Pipedream UI" width="700" src="/images/twitter/twitter-source-in-ui.png"></kbd>
|
|
104
|
-
</p>
|
|
105
|
-
|
|
106
|
-
You can also visit [**https://pipedream.com/sources**](https://pipedream.com/sources) and click the **Create Source** button, then choose the **twitter/twitter-search.js** source from the modal that appears.
|
|
107
|
-
|
|
108
|
-
Then, you can trigger a [**Pipedream workflow**](https://pipedream.com/new) — a serverless Node.js script — on every tweet:
|
|
109
|
-
|
|
110
|
-
<p align="center">
|
|
111
|
-
<kbd><img alt="New workflow source" width="550" src="/images/twitter/new-workflow-source.png"></kbd>
|
|
112
|
-
</p>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
They should work as is, but you can modify them in any way. For example, you can add a step to [**run any Node.js code**](https://docs.pipedream.com/workflows/steps/code/) or use [**pre-built functions**](https://docs.pipedream.com/workflows/steps/actions/) to send data to other destinations.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## SSE and REST APIs
|
|
121
|
-
|
|
122
|
-
Pipedream provides two other interfaces for accessing events produced by sources:
|
|
123
|
-
|
|
124
|
-
+ A private SSE stream specific to your source
|
|
125
|
-
+ A REST API
|
|
126
|
-
|
|
127
|
-
This way, you can run an event source in Pipedream but access its events in your own application.
|
|
128
|
-
|
|
129
|
-
### SSE
|
|
130
|
-
|
|
131
|
-
SSE —[**Server-sent events**](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events)—defines a spec for how servers can send events directly to clients that subscribe to those events, similar to [**WebSockets**](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) and related server-to-client push technologies. If you listen for new items using SSE, **you can run any code in your own application, in real time, as soon as those items are added to the feed.**
|
|
132
|
-
|
|
133
|
-
Streams are private by default. You authenticate by passing your Pipedream API key in the Authorization header:
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
$ curl -H "Authorization: Bearer API_KEY" \
|
|
137
|
-
|
|
138
|
-
https://api.pipedream.com/sources/SOURCE_ID/sse
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
[**See the Pipedream SSE docs**](https://docs.pipedream.com/api/sse) for more information on authentication, example Node code, and other details on the interface.
|
|
142
|
-
|
|
143
|
-
### REST API
|
|
144
|
-
|
|
145
|
-
If you prefer to process tweets in batch, you can fetch them using [**Pipedream's REST API**](https://docs.pipedream.com/api/rest/):
|
|
146
|
-
|
|
147
|
-
```js
|
|
148
|
-
$ curl -H "Authorization: Bearer API_KEY" \
|
|
149
|
-
|
|
150
|
-
https://api.pipedream.com/v1/sources/SOURCE_ID/event_summaries?limit=1
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Note the?limit=1query string. You can vary the number of events returned (most recent first) by setting this param.
|
|
154
|
-
|
|
155
|
-
Please [**reach out**](https://docs.pipedream.com/support/) with any questions or feedback. We're happy to add other Twitter-specific developer resources to this list, and we'd love to hear what can be improved about event sources or the example workflows.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
___
|
|
160
|
-
|
|
161
|
-
<p align="center">
|
|
162
|
-
Pipedream, Inc. — San Francisco, CA
|
|
163
|
-
</p>
|
|
164
|
-
<p align="center">
|
|
165
|
-
<a href="https://twitter.com/PipedreamHQ">Twitter</a> | <a href="https://pipedream.com/community">Community</a> | <a href="https://docs.pipedream.com/">Docs</a> | <a href="https://pipedream.com/terms">Terms</a> |
|
|
166
|
-
<a href="https://pipedream.com/privacy">Privacy</a>
|
|
167
|
-
</p>
|
|
168
|
-
|
|
169
|
-
___
|