├── README.md └── cloud ├── libs ├── oauth.js └── sha1.js └── main.js /README.md: -------------------------------------------------------------------------------- 1 | # Parse-Cloud-Code-Cache-Tweets 2 | Parse Cloud Code for retrieving and storying Tweets from the Twitter API. 3 | 4 | ## Tutorial 5 | You can read the full tutorial here: https://medium.com/@nannerb/tutorial-storing-tweets-in-parse-via-the-twitter-api-9fe2ee092013 6 | 7 | ## To get this script working 8 | 9 | You'll need to modify this line to be the Twitter username you want to use: 10 | ``` 11 | var screenName = "nannerb"; 12 | ``` 13 | And modify these lines to include your Twitter API keys: 14 | ``` 15 | var consumerSecret = ""; 16 | var tokenSecret = ""; 17 | var oauth_consumer_key = ""; 18 | var oauth_token = ""; 19 | ``` 20 | -------------------------------------------------------------------------------- /cloud/libs/oauth.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Netflix, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Here's some JavaScript software for implementing exports. 18 | 19 | This isn't as useful as you might hope. exports is based around 20 | allowing tools and websites to talk to each other. However, 21 | JavaScript running in web browsers is hampered by security 22 | restrictions that prevent code running on one website from 23 | accessing data stored or served on another. 24 | 25 | Before you start hacking, make sure you understand the limitations 26 | posed by cross-domain XMLHttpRequest. 27 | 28 | On the bright side, some platforms use JavaScript as their 29 | language, but enable the programmer to access other web sites. 30 | Examples include Google Gadgets, and Microsoft Vista Sidebar. 31 | For those platforms, this library should come in handy. 32 | */ 33 | 34 | // The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by 35 | // http://pajhome.org.uk/crypt/md5/sha1.js 36 | 37 | /* An exports message is represented as an object like this: 38 | {method: "GET", action: "http://server.com/path", parameters: ...} 39 | 40 | The parameters may be either a map {name: value, name2: value2} 41 | or an Array of name-value pairs [[name, value], [name2, value2]]. 42 | The latter representation is more powerful: it supports parameters 43 | in a specific sequence, or several parameters with the same name; 44 | for example [["a", 1], ["b", 2], ["a", 3]]. 45 | 46 | Parameter names and values are NOT percent-encoded in an object. 47 | They must be encoded before transmission and decoded after reception. 48 | For example, this message object: 49 | {method: "GET", action: "http://server/path", parameters: {p: "x y"}} 50 | ... can be transmitted as an HTTP request that begins: 51 | GET /path?p=x%20y HTTP/1.0 52 | (This isn't a valid exports request, since it lacks a signature etc.) 53 | Note that the object "x y" is transmitted as x%20y. To encode 54 | parameters, you can call exports.addToURL, exports.formEncode or 55 | exports.getAuthorization. 56 | 57 | This message object model harmonizes with the browser object model for 58 | input elements of an form, whose value property isn't percent encoded. 59 | The browser encodes each value before transmitting it. For example, 60 | see consumer.setInputs in example/consumer.js. 61 | */ 62 | 63 | /* This script needs to know what time it is. By default, it uses the local 64 | clock (new Date), which is apt to be inaccurate in browsers. To do 65 | better, you can load this script from a URL whose query string contains 66 | an oauth_timestamp parameter, whose value is a current Unix timestamp. 67 | For example, when generating the enclosing document using PHP: 68 | 69 |