cloudrail_si 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +3 -0
- data/examples/README.md +3 -0
- data/examples/simple/index.rb +11 -0
- data/lib/cloudrail_si.rb +41 -0
- data/lib/cloudrail_si/RedirectReceivers.rb +40 -0
- data/lib/cloudrail_si/Settings.rb +12 -0
- data/lib/cloudrail_si/errors/DetailErrors.rb +13 -0
- data/lib/cloudrail_si/errors/InternalError.rb +10 -0
- data/lib/cloudrail_si/errors/UserError.rb +11 -0
- data/lib/cloudrail_si/helpers/Helper.rb +151 -0
- data/lib/cloudrail_si/helpers/LimitedReadableStream.rb +55 -0
- data/lib/cloudrail_si/helpers/SequenceReadableStream.rb +59 -0
- data/lib/cloudrail_si/servicecode/InitSelfTest.rb +92 -0
- data/lib/cloudrail_si/servicecode/Interpreter.rb +213 -0
- data/lib/cloudrail_si/servicecode/Sandbox.rb +361 -0
- data/lib/cloudrail_si/servicecode/VarAddress.rb +11 -0
- data/lib/cloudrail_si/servicecode/commands/AwaitCodeRedirect.rb +48 -0
- data/lib/cloudrail_si/servicecode/commands/Break.rb +16 -0
- data/lib/cloudrail_si/servicecode/commands/CallFunc.rb +26 -0
- data/lib/cloudrail_si/servicecode/commands/Clone.rb +18 -0
- data/lib/cloudrail_si/servicecode/commands/Concat.rb +22 -0
- data/lib/cloudrail_si/servicecode/commands/Conditional.rb +27 -0
- data/lib/cloudrail_si/servicecode/commands/Create.rb +56 -0
- data/lib/cloudrail_si/servicecode/commands/Delete.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/Get.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/GetMimeType.rb +1005 -0
- data/lib/cloudrail_si/servicecode/commands/JumpRel.rb +18 -0
- data/lib/cloudrail_si/servicecode/commands/Pull.rb +34 -0
- data/lib/cloudrail_si/servicecode/commands/Push.rb +32 -0
- data/lib/cloudrail_si/servicecode/commands/Return.rb +16 -0
- data/lib/cloudrail_si/servicecode/commands/Set.rb +23 -0
- data/lib/cloudrail_si/servicecode/commands/Size.rb +26 -0
- data/lib/cloudrail_si/servicecode/commands/ThrowError.rb +17 -0
- data/lib/cloudrail_si/servicecode/commands/array/Uint8ToBase64.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/debug/Out.rb +24 -0
- data/lib/cloudrail_si/servicecode/commands/hash/md5.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/hash/sha1.rb +30 -0
- data/lib/cloudrail_si/servicecode/commands/http/RequestCall.rb +51 -0
- data/lib/cloudrail_si/servicecode/commands/json/Parse.rb +40 -0
- data/lib/cloudrail_si/servicecode/commands/json/Stringify.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/math/Floor.rb +27 -0
- data/lib/cloudrail_si/servicecode/commands/math/MathCombine.rb +35 -0
- data/lib/cloudrail_si/servicecode/commands/object/GetKeyArray.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/object/GetKeyValueArrays.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/stream/MakeJoinedStream.rb +38 -0
- data/lib/cloudrail_si/servicecode/commands/stream/MakeLimitedStream.rb +23 -0
- data/lib/cloudrail_si/servicecode/commands/stream/StreamToString.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/stream/StringToStream.rb +20 -0
- data/lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb +42 -0
- data/lib/cloudrail_si/servicecode/commands/string/Format.rb +43 -0
- data/lib/cloudrail_si/servicecode/commands/string/IndexOf.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/LastIndexOf.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/Split.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/StringTransform.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/Substr.rb +30 -0
- data/lib/cloudrail_si/servicecode/commands/string/Substring.rb +30 -0
- data/lib/cloudrail_si/services/Facebook.rb +528 -0
- data/lib/cloudrail_si/services/FacebookPage.rb +310 -0
- data/lib/cloudrail_si/services/Foursquare.rb +314 -0
- data/lib/cloudrail_si/services/GitHub.rb +354 -0
- data/lib/cloudrail_si/services/GooglePlaces.rb +309 -0
- data/lib/cloudrail_si/services/GooglePlus.rb +367 -0
- data/lib/cloudrail_si/services/Instagram.rb +342 -0
- data/lib/cloudrail_si/services/LinkedIn.rb +363 -0
- data/lib/cloudrail_si/services/MicrosoftLive.rb +346 -0
- data/lib/cloudrail_si/services/Nexmo.rb +173 -0
- data/lib/cloudrail_si/services/Slack.rb +318 -0
- data/lib/cloudrail_si/services/Twilio.rb +173 -0
- data/lib/cloudrail_si/services/Twitter.rb +795 -0
- data/lib/cloudrail_si/services/Yahoo.rb +408 -0
- data/lib/cloudrail_si/services/Yelp.rb +389 -0
- data/lib/cloudrail_si/statistics/Statistics.rb +125 -0
- data/lib/cloudrail_si/types/Address.rb +9 -0
- data/lib/cloudrail_si/types/Charge.rb +33 -0
- data/lib/cloudrail_si/types/CloudMetaData.rb +19 -0
- data/lib/cloudrail_si/types/CreditCard.rb +76 -0
- data/lib/cloudrail_si/types/Date.rb +49 -0
- data/lib/cloudrail_si/types/DateOfBirth.rb +16 -0
- data/lib/cloudrail_si/types/Error.rb +21 -0
- data/lib/cloudrail_si/types/Location.rb +8 -0
- data/lib/cloudrail_si/types/POI.rb +17 -0
- data/lib/cloudrail_si/types/Refund.rb +25 -0
- data/lib/cloudrail_si/types/SandboxObject.rb +20 -0
- data/lib/cloudrail_si/types/SpaceAllocation.rb +13 -0
- data/lib/cloudrail_si/types/Subscription.rb +27 -0
- data/lib/cloudrail_si/types/SubscriptionPlan.rb +26 -0
- data/lib/cloudrail_si/types/Types.rb +43 -0
- data/lib/cloudrail_si/version.rb +3 -0
- metadata +205 -0
@@ -0,0 +1,173 @@
|
|
1
|
+
require_relative '../servicecode/Interpreter'
|
2
|
+
require_relative '../servicecode/Sandbox'
|
3
|
+
require_relative '../errors/DetailErrors'
|
4
|
+
require_relative '../servicecode/InitSelfTest'
|
5
|
+
require_relative '../statistics/Statistics'
|
6
|
+
|
7
|
+
module CloudRailSi
|
8
|
+
module Services
|
9
|
+
class Twilio
|
10
|
+
|
11
|
+
SERVICE_CODE = {
|
12
|
+
|
13
|
+
"sendSMSTW" => [
|
14
|
+
[ "callFunc", "validateUserInput", "$P0", "$P1", "$P2", "$P3"],
|
15
|
+
[ "create", "$L0", "Object"],
|
16
|
+
[ "set", "$L0.method", "POST"],
|
17
|
+
[ "string.concat", "$L0.url", "https://api.twilio.com/2010-04-01/Accounts/", "$P0.accountSid", "/Messages.json"],
|
18
|
+
[ "string.urlEncode", "$P1", "$P1"],
|
19
|
+
[ "string.urlEncode", "$P2", "$P2"],
|
20
|
+
[ "string.urlEncode", "$P3", "$P3"],
|
21
|
+
[ "string.concat", "$L1", "From=", "$P1", "&To=", "$P2", "&Body=", "$P3"],
|
22
|
+
[ "stream.stringToStream", "$L3", "$L1"],
|
23
|
+
[ "set", "$L0.requestBody", "$L3"],
|
24
|
+
[ "create", "$L0.requestHeaders", "Object"],
|
25
|
+
[ "string.concat", "$L4", "$P0.accountSid", ":", "$P0.authToken"],
|
26
|
+
[ "string.base64encode", "$L5", "$L4"],
|
27
|
+
[ "string.concat", "$L0.requestHeaders.Authorization", "Basic ", "$L5"],
|
28
|
+
[ "set", "$L0.requestHeaders.Content-Type", "application/x-www-form-urlencoded"],
|
29
|
+
[ "create", "$L6", "Object"],
|
30
|
+
[ "http.requestCall", "$L6", "$L0"],
|
31
|
+
[ "callFunc", "validateResponse", "$P0", "$L6"],
|
32
|
+
[ "stream.streamToString", "$L7", "$L6.responseBody"],
|
33
|
+
[ "debug.out", "$L7"]
|
34
|
+
|
35
|
+
],
|
36
|
+
|
37
|
+
"validateUserInput" => [
|
38
|
+
[ "if==than", "$P1", nil, 2],
|
39
|
+
[ "create", "$L1", "Error", "One of the arguments is 'null'. You need to assign a value to it.", "IllegalArgument"],
|
40
|
+
[ "throwError", "$L1"],
|
41
|
+
[ "if==than", "$P2", nil, 2],
|
42
|
+
[ "create", "$L1", "Error", "One of the arguments is 'null'. You need to assign a value to it.", "IllegalArgument"],
|
43
|
+
[ "throwError", "$L1"],
|
44
|
+
[ "if==than", "$P3", nil, 2],
|
45
|
+
[ "create", "$L1", "Error", "One of the arguments is 'null'. You need to assign a value to it.", "IllegalArgument"],
|
46
|
+
[ "throwError", "$L1"],
|
47
|
+
[ "size", "$L2", "$P1"],
|
48
|
+
[ "if==than", "$L2", 0, 2],
|
49
|
+
[ "create", "$L1", "Error", "The 'From' number parameter is empty.", "IllegalArgument"],
|
50
|
+
[ "throwError", "$L1"],
|
51
|
+
[ "size", "$L2", "$P2"],
|
52
|
+
[ "if==than", "$L2", 0, 2],
|
53
|
+
[ "create", "$L1", "Error", "The 'To' number parameter is empty.", "IllegalArgument"],
|
54
|
+
[ "throwError", "$L1"],
|
55
|
+
[ "size", "$L2", "$P3"],
|
56
|
+
[ "if==than", "$L2", 0, 2],
|
57
|
+
[ "create", "$L1", "Error", "The message is empty.", "IllegalArgument"],
|
58
|
+
[ "throwError", "$L1"],
|
59
|
+
[ "size", "$L2", "$P1"],
|
60
|
+
[ "if<than", "$L2", 21, 4],
|
61
|
+
[ "string.lastIndexOf", "$L0", "$P1", "+"],
|
62
|
+
[ "if!=than", "$L0", 0, 2],
|
63
|
+
[ "create", "$L1", "Error", "The 'From' phone number or ID is wrong. It should be either a phone number in E.164 format (e.g. +16175551212) or a MessagingServiceSid (e.g. MGec9516eb5a051a6b2901748b925a5a43).", "IllegalArgument"],
|
64
|
+
[ "throwError", "$L1"],
|
65
|
+
[ "if>than", "$L2", 34, 2],
|
66
|
+
[ "create", "$L1", "Error", "The 'From' phone number or ID is wrong. It should be either a phone number in E.164 format (e.g. +16175551212) or a MessagingServiceSid (e.g. MGec9516eb5a051a6b2901748b925a5a43).", "IllegalArgument"],
|
67
|
+
[ "throwError", "$L1"],
|
68
|
+
[ "string.lastIndexOf", "$L0", "$P2", "+"],
|
69
|
+
[ "if!=than", "$L0", 0, 2],
|
70
|
+
[ "create", "$L1", "Error", "The 'To' phone number isn't in E.164 format. Example: +16175551212", "IllegalArgument"],
|
71
|
+
[ "throwError", "$L1"],
|
72
|
+
[ "size", "$L2", "$P2"],
|
73
|
+
[ "if>than", "$L2", 16, 2],
|
74
|
+
[ "create", "$L1", "Error", "The 'To' phone number is too big, it should have maximum 15 digits. Example: +16175551212", "IllegalArgument"],
|
75
|
+
[ "throwError", "$L1"],
|
76
|
+
[ "size", "$L2", "$P3"],
|
77
|
+
[ "if>than", "$L2", 1600, 2],
|
78
|
+
[ "create", "$L1", "Error", "The length of the message exceeds the 1600 allowed characters.", "IllegalArgument"],
|
79
|
+
[ "throwError", "$L1"]
|
80
|
+
|
81
|
+
],
|
82
|
+
|
83
|
+
"validateResponse" => [
|
84
|
+
[ "if>=than", "$P1.code", 400, 10],
|
85
|
+
[ "if==than", "$P1.code", 401, 2],
|
86
|
+
[ "create", "$L3", "Error", "Invalid credentials or access rights. Make sure that your application has read and write permission.", "Authentication"],
|
87
|
+
[ "throwError", "$L3"],
|
88
|
+
[ "if==than", "$P1.code", 503, 2],
|
89
|
+
[ "create", "$L3", "Error", "Service unavailable. Try again later.", "ServiceUnavailable"],
|
90
|
+
[ "throwError", "$L3"],
|
91
|
+
[ "json.parse", "$L0", "$P1.responseBody"],
|
92
|
+
[ "string.concat", "$L2", "$P1.code", " - ", "$L0.message"],
|
93
|
+
[ "create", "$L3", "Error", "$L2", "Http"],
|
94
|
+
[ "throwError", "$L3"]
|
95
|
+
|
96
|
+
]
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
def initialize(redirect_receiver, account_sid, auth_token)
|
101
|
+
@interpreter_storage = {}
|
102
|
+
@persistent_storage = [{}]
|
103
|
+
@instance_dependency_storage = {
|
104
|
+
redirect_receiver: redirect_receiver
|
105
|
+
}
|
106
|
+
|
107
|
+
ServiceCode::InitSelfTest.init_test('Twilio')
|
108
|
+
|
109
|
+
@interpreter_storage['accountSid'] = account_sid
|
110
|
+
@interpreter_storage['authToken'] = auth_token
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
# call init servicecode function
|
116
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
117
|
+
# check and call the initialization function if is available
|
118
|
+
|
119
|
+
ip.call_function_sync('init', @interpreter_storage) if (SERVICE_CODE['init'])
|
120
|
+
end
|
121
|
+
|
122
|
+
def check_for_error(error)
|
123
|
+
if (error)
|
124
|
+
ServiceCode::Statistics.add_error('Twilio', '')
|
125
|
+
case (error.type)
|
126
|
+
when 'IllegalArgument'
|
127
|
+
raise Errors::IllegalArgumentError.new(error.message)
|
128
|
+
when 'Authentication'
|
129
|
+
raise Errors::AuthenticationError.new(error.message)
|
130
|
+
when 'NotFound'
|
131
|
+
raise Errors::NotFoundError.new(error.message)
|
132
|
+
when 'Http'
|
133
|
+
raise Errors::HttpError.new(error.message)
|
134
|
+
when 'ServiceUnavailable'
|
135
|
+
raise Errors::ServiceUnavailableError.new(error.message)
|
136
|
+
else
|
137
|
+
raise Errors::StandardError.new(error.message)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def send_sms(from_name, to_number, content)
|
144
|
+
ServiceCode::Statistics.add_call('Twilio', 'send_sms')
|
145
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
146
|
+
ip.call_function('sendSMSTW', @interpreter_storage, from_name, to_number, content)
|
147
|
+
|
148
|
+
check_for_error(ip.sandbox.thrown_error)
|
149
|
+
return nil
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def save_as_string
|
154
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
155
|
+
return ip.save_as_string()
|
156
|
+
end
|
157
|
+
|
158
|
+
def load_as_string(saved_state)
|
159
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
160
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
161
|
+
ip.load_as_string(saved_state)
|
162
|
+
@persistent_storage = sandbox.persistent_storage
|
163
|
+
end
|
164
|
+
|
165
|
+
def resume_login(execution_state, callback)
|
166
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
167
|
+
sandbox.load_state_from_string(execution_state)
|
168
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
169
|
+
ip.resume_function('Authenticating:login', @interpreter_storage, callback)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,795 @@
|
|
1
|
+
require_relative '../servicecode/Interpreter'
|
2
|
+
require_relative '../servicecode/Sandbox'
|
3
|
+
require_relative '../errors/DetailErrors'
|
4
|
+
require_relative '../servicecode/InitSelfTest'
|
5
|
+
require_relative '../statistics/Statistics'
|
6
|
+
|
7
|
+
module CloudRailSi
|
8
|
+
module Services
|
9
|
+
class Twitter
|
10
|
+
|
11
|
+
SERVICE_CODE = {
|
12
|
+
|
13
|
+
"Authenticating:login" => [
|
14
|
+
[ "callFunc", "checkAuthentication", "$P0"]
|
15
|
+
|
16
|
+
],
|
17
|
+
|
18
|
+
"Authenticating:logout" => [
|
19
|
+
[ "delete", "$S0.oauthToken"],
|
20
|
+
[ "delete", "$S0.oauthTokenSecret"],
|
21
|
+
[ "set", "$P0.userInfo", nil]
|
22
|
+
|
23
|
+
],
|
24
|
+
|
25
|
+
"Social:postUpdate" => [
|
26
|
+
[ "if==than", "$P1", nil, 2],
|
27
|
+
[ "create", "$L0", "Error", "The status is not allowed to be null.", "IllegalArgument"],
|
28
|
+
[ "throwError", "$L0"],
|
29
|
+
[ "size", "$L0", "$P1"],
|
30
|
+
[ "if>than", "$L0", 140, 2],
|
31
|
+
[ "create", "$L0", "Error", "The status is not allowed to contain more than 140 characters.", "IllegalArgument"],
|
32
|
+
[ "throwError", "$L0"],
|
33
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
34
|
+
[ "callFunc", "post", "$P0", "$P1"]
|
35
|
+
|
36
|
+
],
|
37
|
+
|
38
|
+
"Social:postImage" => [
|
39
|
+
[ "if==than", "$P1", nil, 2],
|
40
|
+
[ "create", "$L0", "Error", "The message is not allowed to be null", "IllegalArgument"],
|
41
|
+
[ "throwError", "$L0"],
|
42
|
+
[ "if==than", "$P2", nil, 2],
|
43
|
+
[ "create", "$L0", "Error", "The image is not allowed to be null", "IllegalArgument"],
|
44
|
+
[ "throwError", "$L0"],
|
45
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
46
|
+
[ "create", "$L0", "Object"],
|
47
|
+
[ "set", "$L0.method", "POST"],
|
48
|
+
[ "set", "$L0.url", "https://upload.twitter.com/1.1/media/upload.json"],
|
49
|
+
[ "create", "$L1", "Array"],
|
50
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
51
|
+
[ "push", "$L1", "oauth_nonce"],
|
52
|
+
[ "push", "$L1", "oauth_signature_method"],
|
53
|
+
[ "push", "$L1", "oauth_timestamp"],
|
54
|
+
[ "push", "$L1", "oauth_token"],
|
55
|
+
[ "push", "$L1", "oauth_version"],
|
56
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1"],
|
57
|
+
[ "create", "$L2", "String", "AaB03xh3u2hfiugiuhuo34gwhoughugheruighui34giuwrgh"],
|
58
|
+
[ "string.concat", "$L0.requestHeaders.Content-Type", "multipart/form-data; boundary=", "$L2"],
|
59
|
+
[ "string.concat", "$L3", "--", "$L2", "\r\n"],
|
60
|
+
[ "string.concat", "$L3", "$L3", "Content-Disposition: form-data; name=\"media\"\r\n"],
|
61
|
+
[ "string.concat", "$L3", "$L3", "Content-Type: application/octet-stream\r\n\r\n"],
|
62
|
+
[ "stream.stringToStream", "$L3", "$L3"],
|
63
|
+
[ "string.concat", "$L4", "\r\n--", "$L2", "--"],
|
64
|
+
[ "stream.stringToStream", "$L4", "$L4"],
|
65
|
+
[ "stream.makeJoinedStream", "$L0.requestBody", "$L3", "$P2", "$L4"],
|
66
|
+
[ "http.requestCall", "$L5", "$L0"],
|
67
|
+
[ "callFunc", "validateResponse", "$P0", "$L5"],
|
68
|
+
[ "json.parse", "$L6", "$L5.responseBody"],
|
69
|
+
[ "set", "$L7", "$L6.media_id_string"],
|
70
|
+
[ "callFunc", "post", "$P0", "$P1", "$L7"]
|
71
|
+
|
72
|
+
],
|
73
|
+
|
74
|
+
"Social:postVideo" => [
|
75
|
+
[ "if==than", "$P1", nil, 2],
|
76
|
+
[ "create", "$L0", "Error", "The message is not allowed to be null", "IllegalArgument"],
|
77
|
+
[ "throwError", "$L0"],
|
78
|
+
[ "if==than", "$P2", nil, 2],
|
79
|
+
[ "create", "$L0", "Error", "The image is not allowed to be null", "IllegalArgument"],
|
80
|
+
[ "throwError", "$L0"],
|
81
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
82
|
+
[ "callFunc", "initUpload", "$P0", "$L0", "$P3", "$P4"],
|
83
|
+
[ "callFunc", "performUpload", "$P0", "$L0", "$P2", "$P3"],
|
84
|
+
[ "callFunc", "finishUpload", "$P0", "$L0"],
|
85
|
+
[ "callFunc", "post", "$P0", "$P1", "$L0"]
|
86
|
+
|
87
|
+
],
|
88
|
+
|
89
|
+
"Social:getConnections" => [
|
90
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
91
|
+
[ "create", "$L0", "Object"],
|
92
|
+
[ "set", "$L0.method", "GET"],
|
93
|
+
[ "set", "$L0.url", "https://api.twitter.com/1.1/friends/ids.json"],
|
94
|
+
[ "create", "$L1", "Array"],
|
95
|
+
[ "push", "$L1", "count"],
|
96
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
97
|
+
[ "push", "$L1", "oauth_nonce"],
|
98
|
+
[ "push", "$L1", "oauth_signature_method"],
|
99
|
+
[ "push", "$L1", "oauth_timestamp"],
|
100
|
+
[ "push", "$L1", "oauth_token"],
|
101
|
+
[ "push", "$L1", "oauth_version"],
|
102
|
+
[ "push", "$L1", "stringify_ids"],
|
103
|
+
[ "create", "$L3", "Object"],
|
104
|
+
[ "set", "$L3.count", "5000"],
|
105
|
+
[ "set", "$L3.stringify_ids", "true"],
|
106
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1", "$L3"],
|
107
|
+
[ "string.concat", "$L0.url", "$L0.url", "?count=5000&stringify_ids=true"],
|
108
|
+
[ "http.requestCall", "$L1", "$L0"],
|
109
|
+
[ "json.parse", "$L2", "$L1.responseBody"],
|
110
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
111
|
+
[ "set", "$L3", "$L2.ids"],
|
112
|
+
[ "create", "$P1", "Array"],
|
113
|
+
[ "create", "$L4", "Number", 0],
|
114
|
+
[ "size", "$L5", "$L3"],
|
115
|
+
[ "if<than", "$L4", "$L5", 5],
|
116
|
+
[ "get", "$L6", "$L3", "$L4"],
|
117
|
+
[ "string.concat", "$L6", "twitter-", "$L6"],
|
118
|
+
[ "push", "$P1", "$L6"],
|
119
|
+
[ "math.add", "$L4", "$L4", 1],
|
120
|
+
[ "jumpRel", -6]
|
121
|
+
|
122
|
+
],
|
123
|
+
|
124
|
+
"Profile:getIdentifier" => [
|
125
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
126
|
+
[ "string.concat", "$P1", "twitter-", "$P0.userInfo.id"]
|
127
|
+
|
128
|
+
],
|
129
|
+
|
130
|
+
"Profile:getFullName" => [
|
131
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
132
|
+
[ "set", "$P1", "$P0.userInfo.name"]
|
133
|
+
|
134
|
+
],
|
135
|
+
|
136
|
+
"Profile:getEmail" => [
|
137
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
138
|
+
[ "set", "$P1", "$P0.userInfo.email"]
|
139
|
+
|
140
|
+
],
|
141
|
+
|
142
|
+
"Profile:getGender" => [
|
143
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
144
|
+
[ "set", "$P1", "$P0.userInfo.gender"]
|
145
|
+
|
146
|
+
],
|
147
|
+
|
148
|
+
"Profile:getDescription" => [
|
149
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
150
|
+
[ "set", "$P1", "$P0.userInfo.description"]
|
151
|
+
|
152
|
+
],
|
153
|
+
|
154
|
+
"Profile:getDateOfBirth" => [
|
155
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
156
|
+
[ "set", "$P1", "$P0.userInfo.dateOfBirth"]
|
157
|
+
|
158
|
+
],
|
159
|
+
|
160
|
+
"Profile:getLocale" => [
|
161
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
162
|
+
[ "set", "$P1", "$P0.userInfo.locale"]
|
163
|
+
|
164
|
+
],
|
165
|
+
|
166
|
+
"Profile:getPictureURL" => [
|
167
|
+
[ "callFunc", "User:getInfo", "$P0"],
|
168
|
+
[ "set", "$P1", "$P0.userInfo.pictureURL"]
|
169
|
+
|
170
|
+
],
|
171
|
+
|
172
|
+
"User:getInfo" => [
|
173
|
+
[ "if!=than", "$P0.userInfo", nil, 4],
|
174
|
+
[ "create", "$L0", "Date"],
|
175
|
+
[ "math.add", "$L0", "$L0.Time", -10000],
|
176
|
+
[ "if>than", "$P0.userInfo.lastUpdate", "$L0", 1],
|
177
|
+
[ "return"],
|
178
|
+
[ "callFunc", "User:sendInfoRequest", "$P0"]
|
179
|
+
|
180
|
+
],
|
181
|
+
|
182
|
+
"User:sendInfoRequest" => [
|
183
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
184
|
+
[ "create", "$L0", "Object"],
|
185
|
+
[ "set", "$L0.method", "GET"],
|
186
|
+
[ "set", "$L0.url", "https://api.twitter.com/1.1/account/verify_credentials.json"],
|
187
|
+
[ "create", "$L1", "Array"],
|
188
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
189
|
+
[ "push", "$L1", "oauth_nonce"],
|
190
|
+
[ "push", "$L1", "oauth_signature_method"],
|
191
|
+
[ "push", "$L1", "oauth_timestamp"],
|
192
|
+
[ "push", "$L1", "oauth_token"],
|
193
|
+
[ "push", "$L1", "oauth_version"],
|
194
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1"],
|
195
|
+
[ "http.requestCall", "$L1", "$L0"],
|
196
|
+
[ "json.parse", "$L2", "$L1.responseBody"],
|
197
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
198
|
+
[ "create", "$P0.userInfo", "Object"],
|
199
|
+
[ "create", "$L3", "Date"],
|
200
|
+
[ "set", "$P0.userInfo.lastUpdate", "$L3.Time"],
|
201
|
+
[ "set", "$P0.userInfo.id", "$L2.id_str"],
|
202
|
+
[ "set", "$P0.userInfo.name", "$L2.name"],
|
203
|
+
[ "set", "$P0.userInfo.email", nil],
|
204
|
+
[ "set", "$P0.userInfo.gender", nil],
|
205
|
+
[ "set", "$P0.userInfo.description", "$L2.description"],
|
206
|
+
[ "create", "$P0.userInfo.dateOfBirth", "DateOfBirth"],
|
207
|
+
[ "set", "$P0.userInfo.locale", "$L2.lang"],
|
208
|
+
[ "set", "$P0.userInfo.pictureURL", "$L2.profile_image_url"]
|
209
|
+
|
210
|
+
],
|
211
|
+
|
212
|
+
"initUpload" => [
|
213
|
+
[ "create", "$L0", "Object"],
|
214
|
+
[ "set", "$L0.method", "POST"],
|
215
|
+
[ "string.concat", "$L0.url", "https://upload.twitter.com/1.1/media/upload.json"],
|
216
|
+
[ "create", "$L1", "Array"],
|
217
|
+
[ "push", "$L1", "command"],
|
218
|
+
[ "push", "$L1", "media_type"],
|
219
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
220
|
+
[ "push", "$L1", "oauth_nonce"],
|
221
|
+
[ "push", "$L1", "oauth_signature_method"],
|
222
|
+
[ "push", "$L1", "oauth_timestamp"],
|
223
|
+
[ "push", "$L1", "oauth_token"],
|
224
|
+
[ "push", "$L1", "oauth_version"],
|
225
|
+
[ "push", "$L1", "total_bytes"],
|
226
|
+
[ "create", "$L2", "Object"],
|
227
|
+
[ "set", "$L2.command", "INIT"],
|
228
|
+
[ "set", "$L2.media_type", "$P3"],
|
229
|
+
[ "string.concat", "$L2.total_bytes", "$P2", ""],
|
230
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1", "$L2"],
|
231
|
+
[ "string.urlEncode", "$L3", "$P3"],
|
232
|
+
[ "string.concat", "$L3", "command=INIT&media_type=", "$L3", "&total_bytes=", "$P2"],
|
233
|
+
[ "stream.stringToStream", "$L0.requestBody", "$L3"],
|
234
|
+
[ "set", "$L0.requestHeaders.Content-Type", "application/x-www-form-urlencoded"],
|
235
|
+
[ "http.requestCall", "$L4", "$L0"],
|
236
|
+
[ "callFunc", "validateResponse", "$P0", "$L4"],
|
237
|
+
[ "json.parse", "$L5", "$L4.responseBody"],
|
238
|
+
[ "set", "$P1", "$L5.media_id_string"]
|
239
|
+
|
240
|
+
],
|
241
|
+
|
242
|
+
"performUpload" => [
|
243
|
+
[ "create", "$L20", "Number", 2097152],
|
244
|
+
[ "create", "$L21", "Number", 0],
|
245
|
+
[ "create", "$L22", "Number", 1],
|
246
|
+
[ "if<than", "$L22", "$P3", 35],
|
247
|
+
[ "create", "$L0", "Object"],
|
248
|
+
[ "set", "$L0.method", "POST"],
|
249
|
+
[ "string.concat", "$L0.url", "https://upload.twitter.com/1.1/media/upload.json"],
|
250
|
+
[ "create", "$L1", "Array"],
|
251
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
252
|
+
[ "push", "$L1", "oauth_nonce"],
|
253
|
+
[ "push", "$L1", "oauth_signature_method"],
|
254
|
+
[ "push", "$L1", "oauth_timestamp"],
|
255
|
+
[ "push", "$L1", "oauth_token"],
|
256
|
+
[ "push", "$L1", "oauth_version"],
|
257
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1"],
|
258
|
+
[ "create", "$L2", "String", "AaB03xh3u2hfiugiuhuo34gwhoughugheruighui34giuwrgh"],
|
259
|
+
[ "string.concat", "$L3", "--", "$L2", "\r\n"],
|
260
|
+
[ "string.concat", "$L3", "$L3", "Content-Disposition: form-data; name=\"command\"\r\n\r\n"],
|
261
|
+
[ "string.concat", "$L3", "$L3", "APPEND\r\n"],
|
262
|
+
[ "string.concat", "$L3", "$L3", "--", "$L2", "\r\n"],
|
263
|
+
[ "string.concat", "$L3", "$L3", "Content-Disposition: form-data; name=\"media_id\"\r\n\r\n"],
|
264
|
+
[ "string.concat", "$L3", "$L3", "$P1", "\r\n"],
|
265
|
+
[ "string.concat", "$L3", "$L3", "--", "$L2", "\r\n"],
|
266
|
+
[ "string.concat", "$L3", "$L3", "Content-Disposition: form-data; name=\"segment_index\"\r\n\r\n"],
|
267
|
+
[ "string.concat", "$L3", "$L3", "$L21", "\r\n"],
|
268
|
+
[ "string.concat", "$L3", "$L3", "--", "$L2", "\r\n"],
|
269
|
+
[ "string.concat", "$L3", "$L3", "Content-Disposition: form-data; name=\"media\"\r\n"],
|
270
|
+
[ "string.concat", "$L3", "$L3", "Content-Type: application/octet-stream\r\n\r\n"],
|
271
|
+
[ "stream.stringToStream", "$L3", "$L3"],
|
272
|
+
[ "stream.makeLimitedStream", "$L23", "$P2", "$L20"],
|
273
|
+
[ "string.concat", "$L4", "\r\n--", "$L2", "--"],
|
274
|
+
[ "stream.stringToStream", "$L4", "$L4"],
|
275
|
+
[ "stream.makeJoinedStream", "$L0.requestBody", "$L3", "$L23", "$L4"],
|
276
|
+
[ "string.concat", "$L0.requestHeaders.Content-Type", "multipart/form-data; boundary=", "$L2"],
|
277
|
+
[ "http.requestCall", "$L5", "$L0"],
|
278
|
+
[ "callFunc", "validateResponse", "$P0", "$L5"],
|
279
|
+
[ "math.add", "$L22", "$L22", "$L20"],
|
280
|
+
[ "math.add", "$L21", "$L21", 1],
|
281
|
+
[ "jumpRel", -36]
|
282
|
+
|
283
|
+
],
|
284
|
+
|
285
|
+
"finishUpload" => [
|
286
|
+
[ "create", "$L0", "Object"],
|
287
|
+
[ "set", "$L0.method", "POST"],
|
288
|
+
[ "string.concat", "$L0.url", "https://upload.twitter.com/1.1/media/upload.json"],
|
289
|
+
[ "create", "$L1", "Array"],
|
290
|
+
[ "push", "$L1", "command"],
|
291
|
+
[ "push", "$L1", "media_id"],
|
292
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
293
|
+
[ "push", "$L1", "oauth_nonce"],
|
294
|
+
[ "push", "$L1", "oauth_signature_method"],
|
295
|
+
[ "push", "$L1", "oauth_timestamp"],
|
296
|
+
[ "push", "$L1", "oauth_token"],
|
297
|
+
[ "push", "$L1", "oauth_version"],
|
298
|
+
[ "create", "$L2", "Object"],
|
299
|
+
[ "set", "$L2.command", "FINALIZE"],
|
300
|
+
[ "set", "$L2.media_id", "$P1"],
|
301
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1", "$L2"],
|
302
|
+
[ "string.concat", "$L3", "command=FINALIZE&media_id=", "$P1"],
|
303
|
+
[ "stream.stringToStream", "$L0.requestBody", "$L3"],
|
304
|
+
[ "set", "$L0.requestHeaders.Content-Type", "application/x-www-form-urlencoded"],
|
305
|
+
[ "http.requestCall", "$L4", "$L0"],
|
306
|
+
[ "callFunc", "validateResponse", "$P0", "$L4"]
|
307
|
+
|
308
|
+
],
|
309
|
+
|
310
|
+
"post" => [
|
311
|
+
[ "string.urlEncode", "$L3", "$P1"],
|
312
|
+
[ "callFunc", "urlEncode", "$P0", "$L5", "$L3"],
|
313
|
+
[ "create", "$L0", "Object"],
|
314
|
+
[ "set", "$L0.method", "POST"],
|
315
|
+
[ "string.concat", "$L0.url", "https://api.twitter.com/1.1/statuses/update.json"],
|
316
|
+
[ "create", "$L1", "Array"],
|
317
|
+
[ "if!=than", "$P2", nil, 1],
|
318
|
+
[ "push", "$L1", "media_ids"],
|
319
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
320
|
+
[ "push", "$L1", "oauth_nonce"],
|
321
|
+
[ "push", "$L1", "oauth_signature_method"],
|
322
|
+
[ "push", "$L1", "oauth_timestamp"],
|
323
|
+
[ "push", "$L1", "oauth_token"],
|
324
|
+
[ "push", "$L1", "oauth_version"],
|
325
|
+
[ "push", "$L1", "status"],
|
326
|
+
[ "create", "$L4", "Object"],
|
327
|
+
[ "set", "$L4.status", "$P1"],
|
328
|
+
[ "if!=than", "$P2", nil, 1],
|
329
|
+
[ "set", "$L4.media_ids", "$P2"],
|
330
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1", "$L4"],
|
331
|
+
[ "string.concat", "$L21", "status=", "$L5"],
|
332
|
+
[ "if!=than", "$P2", nil, 1],
|
333
|
+
[ "string.concat", "$L21", "$L21", "&media_ids=", "$P2"],
|
334
|
+
[ "stream.stringToStream", "$L0.requestBody", "$L21"],
|
335
|
+
[ "set", "$L0.requestHeaders.Content-Type", "application/x-www-form-urlencoded"],
|
336
|
+
[ "http.requestCall", "$L1", "$L0"],
|
337
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"]
|
338
|
+
|
339
|
+
],
|
340
|
+
|
341
|
+
"AdvancedRequestSupporter:advancedRequest" => [
|
342
|
+
[ "create", "$L0", "Object"],
|
343
|
+
[ "create", "$L0.url", "String"],
|
344
|
+
[ "if!=than", "$P2.appendBaseUrl", 0, 1],
|
345
|
+
[ "set", "$L0.url", "https://api.twitter.com/1.1"],
|
346
|
+
[ "string.concat", "$L0.url", "$L0.url", "$P2.url"],
|
347
|
+
[ "set", "$L0.requestHeaders", "$P2.headers"],
|
348
|
+
[ "set", "$L0.method", "$P2.method"],
|
349
|
+
[ "if==than", "$P2.headers.Content-Type", "application/x-www-form-urlencoded", 3],
|
350
|
+
[ "stream.streamToString", "$L10", "$P2.body"],
|
351
|
+
[ "stream.stringToStream", "$L0.requestBody", "$L10"],
|
352
|
+
[ "jumpRel", 1],
|
353
|
+
[ "set", "$L0.requestBody", "$P2.body"],
|
354
|
+
[ "if!=than", "$P2.appendAuthorization", 0, 21],
|
355
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
356
|
+
[ "string.split", "$L2", "$P2.url", "\\?", 2],
|
357
|
+
[ "size", "$L3", "$L2"],
|
358
|
+
[ "create", "$L4", "String"],
|
359
|
+
[ "if==than", "$L3", 2, 1],
|
360
|
+
[ "get", "$L4", "$L2", 1],
|
361
|
+
[ "if==than", "$P2.headers.Content-Type", "application/x-www-form-urlencoded", 4],
|
362
|
+
[ "size", "$L6", "$L4"],
|
363
|
+
[ "if>than", "$L6", 0, 1],
|
364
|
+
[ "string.concat", "$L4", "$L4", "&"],
|
365
|
+
[ "string.concat", "$L4", "$L4", "$L10"],
|
366
|
+
[ "callFunc", "extractParameters", "$P0", "$L6", "$L4"],
|
367
|
+
[ "object.getKeyArray", "$L5", "$L6"],
|
368
|
+
[ "push", "$L5", "oauth_consumer_key"],
|
369
|
+
[ "push", "$L5", "oauth_nonce"],
|
370
|
+
[ "push", "$L5", "oauth_signature_method"],
|
371
|
+
[ "push", "$L5", "oauth_timestamp"],
|
372
|
+
[ "push", "$L5", "oauth_token"],
|
373
|
+
[ "push", "$L5", "oauth_version"],
|
374
|
+
[ "array.sort", "$L5", "$L5"],
|
375
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L5", "$L6"],
|
376
|
+
[ "http.requestCall", "$L1", "$L0"],
|
377
|
+
[ "if!=than", "$P2.checkErrors", 0, 1],
|
378
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
379
|
+
[ "create", "$P1", "AdvancedRequestResponse"],
|
380
|
+
[ "set", "$P1.status", "$L1.code"],
|
381
|
+
[ "set", "$P1.headers", "$L1.responseHeaders"],
|
382
|
+
[ "set", "$P1.body", "$L1.responseBody"]
|
383
|
+
|
384
|
+
],
|
385
|
+
|
386
|
+
"extractParameters" => [
|
387
|
+
[ "create", "$P1", "Object"],
|
388
|
+
[ "size", "$L0", "$P2"],
|
389
|
+
[ "if==than", "$L0", 0, 1],
|
390
|
+
[ "return"],
|
391
|
+
[ "string.split", "$L1", "$P2", "&"],
|
392
|
+
[ "size", "$L2", "$L1"],
|
393
|
+
[ "set", "$L3", 0],
|
394
|
+
[ "if<than", "$L3", "$L2", 7],
|
395
|
+
[ "get", "$L4", "$L1", "$L3"],
|
396
|
+
[ "string.split", "$L5", "$L4", "=", 2],
|
397
|
+
[ "get", "$L6", "$L5", 0],
|
398
|
+
[ "get", "$L7", "$L5", 1],
|
399
|
+
[ "set", "$P1", "$L7", "$L6"],
|
400
|
+
[ "math.add", "$L3", "$L3", 1],
|
401
|
+
[ "jumpRel", -8]
|
402
|
+
|
403
|
+
],
|
404
|
+
|
405
|
+
"oAuth1:signRequest" => [
|
406
|
+
[ "if==than", "$P1.requestHeaders", nil, 1],
|
407
|
+
[ "create", "$P1.requestHeaders", "Object"],
|
408
|
+
[ "create", "$L0", "Object"],
|
409
|
+
[ "set", "$L0.oauth_consumer_key", "$P0.clientID"],
|
410
|
+
[ "callFunc", "oAuth1:generateNonce", "$L0.oauth_nonce"],
|
411
|
+
[ "set", "$L0.oauth_signature_method", "HMAC-SHA1"],
|
412
|
+
[ "create", "$L1", "Date"],
|
413
|
+
[ "math.multiply", "$L1", "$L1.Time", 0.001],
|
414
|
+
[ "math.floor", "$L1", "$L1"],
|
415
|
+
[ "string.format", "$L0.oauth_timestamp", "%d", "$L1"],
|
416
|
+
[ "set", "$L0.oauth_token", "$S0.oauthToken"],
|
417
|
+
[ "set", "$L0.oauth_version", "1.0"],
|
418
|
+
[ "string.split", "$L2", "$P1.url", "\\?", 2],
|
419
|
+
[ "get", "$L2", "$L2", 0],
|
420
|
+
[ "string.urlEncode", "$L2", "$L2"],
|
421
|
+
[ "string.concat", "$L1", "$P1.method", "&", "$L2", "&"],
|
422
|
+
[ "set", "$L2", ""],
|
423
|
+
[ "set", "$L3", 0],
|
424
|
+
[ "size", "$L4", "$P2"],
|
425
|
+
[ "if<than", "$L3", "$L4", 15],
|
426
|
+
[ "get", "$L5", "$P2", "$L3"],
|
427
|
+
[ "if==than", "$L5", "oauth_callback", 1],
|
428
|
+
[ "set", "$L0.oauth_callback", "$P0.redirectUri"],
|
429
|
+
[ "get", "$L6", "$L0", "$L5"],
|
430
|
+
[ "if>than", "$L3", 0, 1],
|
431
|
+
[ "string.concat", "$L2", "$L2", "&"],
|
432
|
+
[ "if==than", "$L6", nil, 1],
|
433
|
+
[ "get", "$L6", "$P3", "$L5"],
|
434
|
+
[ "string.urlEncode", "$L6", "$L6"],
|
435
|
+
[ "if==than", "$L5", "status", 2],
|
436
|
+
[ "callFunc", "urlEncode", "$P0", "$L20", "$L6"],
|
437
|
+
[ "set", "$L6", "$L20"],
|
438
|
+
[ "string.concat", "$L2", "$L2", "$L5", "=", "$L6"],
|
439
|
+
[ "math.add", "$L3", "$L3", 1],
|
440
|
+
[ "jumpRel", -16],
|
441
|
+
[ "string.urlEncode", "$L2", "$L2"],
|
442
|
+
[ "string.concat", "$L1", "$L1", "$L2"],
|
443
|
+
[ "set", "$L2", "$S0.oauthTokenSecret"],
|
444
|
+
[ "if==than", "$L2", nil, 1],
|
445
|
+
[ "set", "$L2", ""],
|
446
|
+
[ "string.concat", "$L2", "$P0.clientSecret", "&", "$L2"],
|
447
|
+
[ "crypt.hmac.sha1", "$L2", "$L2", "$L1"],
|
448
|
+
[ "array.uint8ToBase64", "$L2", "$L2"],
|
449
|
+
[ "string.urlEncode", "$L2", "$L2"],
|
450
|
+
[ "set", "$L0.oauth_signature", "$L2"],
|
451
|
+
[ "set", "$L2", "OAuth "],
|
452
|
+
[ "if!=than", "$L0.oauth_callback", nil, 2],
|
453
|
+
[ "string.urlEncode", "$L3", "$L0.oauth_callback"],
|
454
|
+
[ "string.concat", "$L2", "$L2", "oauth_callback", "=\"", "$L3", "\"", ", "],
|
455
|
+
[ "string.concat", "$L2", "$L2", "oauth_consumer_key", "=\"", "$L0.oauth_consumer_key", "\""],
|
456
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_nonce", "=\"", "$L0.oauth_nonce", "\""],
|
457
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_signature", "=\"", "$L0.oauth_signature", "\""],
|
458
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_signature_method", "=\"", "$L0.oauth_signature_method", "\""],
|
459
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_timestamp", "=\"", "$L0.oauth_timestamp", "\""],
|
460
|
+
[ "if!=than", "$L0.oauth_token", nil, 1],
|
461
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_token", "=\"", "$L0.oauth_token", "\""],
|
462
|
+
[ "string.concat", "$L2", "$L2", ", ", "oauth_version", "=\"", "$L0.oauth_version", "\""],
|
463
|
+
[ "set", "$P1.requestHeaders.Authorization", "$L2"]
|
464
|
+
|
465
|
+
],
|
466
|
+
|
467
|
+
"oAuth1:generateNonce" => [
|
468
|
+
[ "create", "$L0", "Date"],
|
469
|
+
[ "string.format", "$L0", "%d", "$L0.Time"],
|
470
|
+
[ "hash.md5", "$L0", "$L0"],
|
471
|
+
[ "size", "$L1", "$L0"],
|
472
|
+
[ "set", "$L2", 0],
|
473
|
+
[ "set", "$P0", ""],
|
474
|
+
[ "get", "$L3", "$L0", "$L2"],
|
475
|
+
[ "string.format", "$L4", "%02x", "$L3"],
|
476
|
+
[ "string.concat", "$P0", "$P0", "$L4"],
|
477
|
+
[ "math.add", "$L2", "$L2", 1],
|
478
|
+
[ "if>=than", "$L2", "$L1", -5]
|
479
|
+
|
480
|
+
],
|
481
|
+
|
482
|
+
"urlEncode" => [
|
483
|
+
[ "string.split", "$L0", "$P2", "\\+"],
|
484
|
+
[ "size", "$L1", "$L0"],
|
485
|
+
[ "create", "$L2", "Number"],
|
486
|
+
[ "set", "$L2", 0],
|
487
|
+
[ "create", "$L4", "String"],
|
488
|
+
[ "if<than", "$L2", "$L1", 7],
|
489
|
+
[ "get", "$L5", "$L0", "$L2"],
|
490
|
+
[ "if==than", "$L2", 0, 2],
|
491
|
+
[ "set", "$L4", "$L5"],
|
492
|
+
[ "jumpRel", 1],
|
493
|
+
[ "string.concat", "$L4", "$L4", "%20", "$L5"],
|
494
|
+
[ "math.add", "$L2", "$L2", 1],
|
495
|
+
[ "jumpRel", -8],
|
496
|
+
[ "set", "$P1", "$L4"]
|
497
|
+
|
498
|
+
],
|
499
|
+
|
500
|
+
"checkAuthentication" => [
|
501
|
+
[ "if!=than", "$S0.oauthToken", nil, 2],
|
502
|
+
[ "if!=than", "$S0.oauthTokenSecret", nil, 1],
|
503
|
+
[ "return"],
|
504
|
+
[ "callFunc", "authenticate", "$P0"]
|
505
|
+
|
506
|
+
],
|
507
|
+
|
508
|
+
"authenticate" => [
|
509
|
+
[ "create", "$L0", "Object"],
|
510
|
+
[ "set", "$L0.method", "POST"],
|
511
|
+
[ "set", "$L0.url", "https://api.twitter.com/oauth/request_token"],
|
512
|
+
[ "create", "$L1", "Array"],
|
513
|
+
[ "push", "$L1", "oauth_callback"],
|
514
|
+
[ "push", "$L1", "oauth_consumer_key"],
|
515
|
+
[ "push", "$L1", "oauth_nonce"],
|
516
|
+
[ "push", "$L1", "oauth_signature_method"],
|
517
|
+
[ "push", "$L1", "oauth_timestamp"],
|
518
|
+
[ "push", "$L1", "oauth_version"],
|
519
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L0", "$L1"],
|
520
|
+
[ "http.requestCall", "$L1", "$L0"],
|
521
|
+
[ "if!=than", "$L1.code", 200, 3],
|
522
|
+
[ "stream.streamToString", "$L2", "$L1.responseBody"],
|
523
|
+
[ "create", "$L3", "Error", "$L2", "Authentication"],
|
524
|
+
[ "throwError", "$L3"],
|
525
|
+
[ "stream.streamToString", "$L2", "$L1.responseBody"],
|
526
|
+
[ "string.split", "$L2", "$L2", "&"],
|
527
|
+
[ "set", "$L3", 0],
|
528
|
+
[ "size", "$L4", "$L2"],
|
529
|
+
[ "create", "$L0", "Object"],
|
530
|
+
[ "if<than", "$L3", "$L4", 8],
|
531
|
+
[ "get", "$L5", "$L2", "$L3"],
|
532
|
+
[ "string.split", "$L6", "$L5", "=", 2],
|
533
|
+
[ "get", "$L7", "$L6", 0],
|
534
|
+
[ "get", "$L8", "$L6", 1],
|
535
|
+
[ "string.urlDecode", "$L8", "$L8"],
|
536
|
+
[ "set", "$L0", "$L8", "$L7"],
|
537
|
+
[ "math.add", "$L3", "$L3", 1],
|
538
|
+
[ "jumpRel", -9],
|
539
|
+
[ "string.concat", "$L3", "https://api.twitter.com/oauth/authenticate?oauth_token=", "$L0.oauth_token"],
|
540
|
+
[ "awaitCodeRedirect", "$L3", "$L3", "oauth_token", "oauth_verifier"],
|
541
|
+
[ "set", "$S0.oauthToken", "$L3.oauth_token"],
|
542
|
+
[ "create", "$L4", "Object"],
|
543
|
+
[ "set", "$L4.method", "POST"],
|
544
|
+
[ "set", "$L4.url", "https://api.twitter.com/oauth/access_token"],
|
545
|
+
[ "create", "$L4.requestHeaders", "Object"],
|
546
|
+
[ "set", "$L4.requestHeaders.Content-Type", "application/x-www-form-urlencoded"],
|
547
|
+
[ "string.urlEncode", "$L5", "$L3.oauth_verifier"],
|
548
|
+
[ "string.concat", "$L5", "oauth_verifier=", "$L5"],
|
549
|
+
[ "stream.stringToStream", "$L4.requestBody", "$L5"],
|
550
|
+
[ "create", "$L6", "Object"],
|
551
|
+
[ "set", "$L6.oauth_verifier", "$L3.oauth_verifier"],
|
552
|
+
[ "create", "$L7", "Array"],
|
553
|
+
[ "push", "$L7", "oauth_callback"],
|
554
|
+
[ "push", "$L7", "oauth_consumer_key"],
|
555
|
+
[ "push", "$L7", "oauth_nonce"],
|
556
|
+
[ "push", "$L7", "oauth_signature_method"],
|
557
|
+
[ "push", "$L7", "oauth_timestamp"],
|
558
|
+
[ "push", "$L7", "oauth_verifier"],
|
559
|
+
[ "push", "$L7", "oauth_version"],
|
560
|
+
[ "callFunc", "oAuth1:signRequest", "$P0", "$L4", "$L7", "$L6"],
|
561
|
+
[ "http.requestCall", "$L9", "$L4"],
|
562
|
+
[ "if!=than", "$L9.code", 200, 3],
|
563
|
+
[ "stream.streamToString", "$L10", "$L9.responseBody"],
|
564
|
+
[ "create", "$L11", "Error", "$L10", "Authentication"],
|
565
|
+
[ "throwError", "$L11"],
|
566
|
+
[ "stream.streamToString", "$L10", "$L9.responseBody"],
|
567
|
+
[ "string.split", "$L10", "$L10", "&"],
|
568
|
+
[ "set", "$L11", 0],
|
569
|
+
[ "size", "$L12", "$L10"],
|
570
|
+
[ "create", "$L13", "Object"],
|
571
|
+
[ "if<than", "$L11", "$L12", 8],
|
572
|
+
[ "get", "$L14", "$L10", "$L11"],
|
573
|
+
[ "string.split", "$L15", "$L14", "=", 2],
|
574
|
+
[ "get", "$L16", "$L15", 0],
|
575
|
+
[ "get", "$L17", "$L15", 1],
|
576
|
+
[ "string.urlDecode", "$L17", "$L17"],
|
577
|
+
[ "set", "$L13", "$L17", "$L16"],
|
578
|
+
[ "math.add", "$L11", "$L11", 1],
|
579
|
+
[ "jumpRel", -9],
|
580
|
+
[ "string.urlDecode", "$S0.oauthToken", "$L13.oauth_token"],
|
581
|
+
[ "string.urlDecode", "$S0.oauthTokenSecret", "$L13.oauth_token_secret"]
|
582
|
+
|
583
|
+
],
|
584
|
+
|
585
|
+
"validateResponse" => [
|
586
|
+
[ "if>=than", "$P1.code", 400, 3],
|
587
|
+
[ "stream.streamToString", "$L2", "$P1.responseBody"],
|
588
|
+
[ "create", "$L3", "Error", "$L2", "Http"],
|
589
|
+
[ "throwError", "$L3"]
|
590
|
+
|
591
|
+
]
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
def initialize(redirect_receiver, client_id, client_secret, redirect_uri)
|
596
|
+
@interpreter_storage = {}
|
597
|
+
@persistent_storage = [{}]
|
598
|
+
@instance_dependency_storage = {
|
599
|
+
redirect_receiver: redirect_receiver
|
600
|
+
}
|
601
|
+
|
602
|
+
ServiceCode::InitSelfTest.init_test('Twitter')
|
603
|
+
|
604
|
+
@interpreter_storage['clientID'] = client_id
|
605
|
+
@interpreter_storage['clientSecret'] = client_secret
|
606
|
+
@interpreter_storage['redirectUri'] = redirect_uri
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
# call init servicecode function
|
612
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
613
|
+
# check and call the initialization function if is available
|
614
|
+
|
615
|
+
ip.call_function_sync('init', @interpreter_storage) if (SERVICE_CODE['init'])
|
616
|
+
end
|
617
|
+
|
618
|
+
def check_for_error(error)
|
619
|
+
if (error)
|
620
|
+
ServiceCode::Statistics.add_error('Twitter', '')
|
621
|
+
case (error.type)
|
622
|
+
when 'IllegalArgument'
|
623
|
+
raise Errors::IllegalArgumentError.new(error.message)
|
624
|
+
when 'Authentication'
|
625
|
+
raise Errors::AuthenticationError.new(error.message)
|
626
|
+
when 'NotFound'
|
627
|
+
raise Errors::NotFoundError.new(error.message)
|
628
|
+
when 'Http'
|
629
|
+
raise Errors::HttpError.new(error.message)
|
630
|
+
when 'ServiceUnavailable'
|
631
|
+
raise Errors::ServiceUnavailableError.new(error.message)
|
632
|
+
else
|
633
|
+
raise Errors::StandardError.new(error.message)
|
634
|
+
end
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
|
639
|
+
def get_identifier()
|
640
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_identifier')
|
641
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
642
|
+
ip.call_function('Profile:getIdentifier', @interpreter_storage, nil)
|
643
|
+
|
644
|
+
check_for_error(ip.sandbox.thrown_error)
|
645
|
+
return nil || ip.get_parameter(1)
|
646
|
+
end
|
647
|
+
|
648
|
+
def get_full_name()
|
649
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_full_name')
|
650
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
651
|
+
ip.call_function('Profile:getFullName', @interpreter_storage, nil)
|
652
|
+
|
653
|
+
check_for_error(ip.sandbox.thrown_error)
|
654
|
+
return nil || ip.get_parameter(1)
|
655
|
+
end
|
656
|
+
|
657
|
+
def get_email()
|
658
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_email')
|
659
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
660
|
+
ip.call_function('Profile:getEmail', @interpreter_storage, nil)
|
661
|
+
|
662
|
+
check_for_error(ip.sandbox.thrown_error)
|
663
|
+
return nil || ip.get_parameter(1)
|
664
|
+
end
|
665
|
+
|
666
|
+
def get_gender()
|
667
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_gender')
|
668
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
669
|
+
ip.call_function('Profile:getGender', @interpreter_storage, nil)
|
670
|
+
|
671
|
+
check_for_error(ip.sandbox.thrown_error)
|
672
|
+
return nil || ip.get_parameter(1)
|
673
|
+
end
|
674
|
+
|
675
|
+
def get_description()
|
676
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_description')
|
677
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
678
|
+
ip.call_function('Profile:getDescription', @interpreter_storage, nil)
|
679
|
+
|
680
|
+
check_for_error(ip.sandbox.thrown_error)
|
681
|
+
return nil || ip.get_parameter(1)
|
682
|
+
end
|
683
|
+
|
684
|
+
def get_date_of_birth()
|
685
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_date_of_birth')
|
686
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
687
|
+
ip.call_function('Profile:getDateOfBirth', @interpreter_storage, nil)
|
688
|
+
|
689
|
+
check_for_error(ip.sandbox.thrown_error)
|
690
|
+
return nil || ip.get_parameter(1)
|
691
|
+
end
|
692
|
+
|
693
|
+
def get_locale()
|
694
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_locale')
|
695
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
696
|
+
ip.call_function('Profile:getLocale', @interpreter_storage, nil)
|
697
|
+
|
698
|
+
check_for_error(ip.sandbox.thrown_error)
|
699
|
+
return nil || ip.get_parameter(1)
|
700
|
+
end
|
701
|
+
|
702
|
+
def get_picture_url()
|
703
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_picture_url')
|
704
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
705
|
+
ip.call_function('Profile:getPictureURL', @interpreter_storage, nil)
|
706
|
+
|
707
|
+
check_for_error(ip.sandbox.thrown_error)
|
708
|
+
return nil || ip.get_parameter(1)
|
709
|
+
end
|
710
|
+
|
711
|
+
def login()
|
712
|
+
ServiceCode::Statistics.add_call('Twitter', 'login')
|
713
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
714
|
+
ip.call_function('Authenticating:login', @interpreter_storage)
|
715
|
+
|
716
|
+
check_for_error(ip.sandbox.thrown_error)
|
717
|
+
return nil
|
718
|
+
end
|
719
|
+
|
720
|
+
def logout()
|
721
|
+
ServiceCode::Statistics.add_call('Twitter', 'logout')
|
722
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
723
|
+
ip.call_function('Authenticating:logout', @interpreter_storage)
|
724
|
+
|
725
|
+
check_for_error(ip.sandbox.thrown_error)
|
726
|
+
return nil
|
727
|
+
end
|
728
|
+
|
729
|
+
def advanced_request(specification)
|
730
|
+
ServiceCode::Statistics.add_call('Twitter', 'advanced_request')
|
731
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
732
|
+
ip.call_function('AdvancedRequestSupporter:advancedRequest', @interpreter_storage, nil, specification)
|
733
|
+
|
734
|
+
check_for_error(ip.sandbox.thrown_error)
|
735
|
+
return nil || ip.get_parameter(1)
|
736
|
+
end
|
737
|
+
|
738
|
+
def post_update(content)
|
739
|
+
ServiceCode::Statistics.add_call('Twitter', 'post_update')
|
740
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
741
|
+
ip.call_function('Social:postUpdate', @interpreter_storage, content)
|
742
|
+
|
743
|
+
check_for_error(ip.sandbox.thrown_error)
|
744
|
+
return nil
|
745
|
+
end
|
746
|
+
|
747
|
+
def post_image(message, image)
|
748
|
+
ServiceCode::Statistics.add_call('Twitter', 'post_image')
|
749
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
750
|
+
ip.call_function('Social:postImage', @interpreter_storage, message, image)
|
751
|
+
|
752
|
+
check_for_error(ip.sandbox.thrown_error)
|
753
|
+
return nil
|
754
|
+
end
|
755
|
+
|
756
|
+
def post_video(message, video, size, mime_type)
|
757
|
+
ServiceCode::Statistics.add_call('Twitter', 'post_video')
|
758
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
759
|
+
ip.call_function('Social:postVideo', @interpreter_storage, message, video, size, mime_type)
|
760
|
+
|
761
|
+
check_for_error(ip.sandbox.thrown_error)
|
762
|
+
return nil
|
763
|
+
end
|
764
|
+
|
765
|
+
def get_connections()
|
766
|
+
ServiceCode::Statistics.add_call('Twitter', 'get_connections')
|
767
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
768
|
+
ip.call_function('Social:getConnections', @interpreter_storage, nil)
|
769
|
+
|
770
|
+
check_for_error(ip.sandbox.thrown_error)
|
771
|
+
return nil || ip.get_parameter(1)
|
772
|
+
end
|
773
|
+
|
774
|
+
|
775
|
+
def save_as_string
|
776
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
777
|
+
return ip.save_as_string()
|
778
|
+
end
|
779
|
+
|
780
|
+
def load_as_string(saved_state)
|
781
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
782
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
783
|
+
ip.load_as_string(saved_state)
|
784
|
+
@persistent_storage = sandbox.persistent_storage
|
785
|
+
end
|
786
|
+
|
787
|
+
def resume_login(execution_state, callback)
|
788
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
789
|
+
sandbox.load_state_from_string(execution_state)
|
790
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
791
|
+
ip.resume_function('Authenticating:login', @interpreter_storage, callback)
|
792
|
+
end
|
793
|
+
end
|
794
|
+
end
|
795
|
+
end
|