diff --git a/ChromeExtensionExamples/BasicPopup/icon.png b/ChromeExtensionExamples/BasicPopup/icon.png new file mode 100644 index 0000000..0fe39b0 Binary files /dev/null and b/ChromeExtensionExamples/BasicPopup/icon.png differ diff --git a/ChromeExtensionExamples/BasicPopup/manifest.json b/ChromeExtensionExamples/BasicPopup/manifest.json new file mode 100644 index 0000000..9496aca --- /dev/null +++ b/ChromeExtensionExamples/BasicPopup/manifest.json @@ -0,0 +1,15 @@ +{ + "manifest_version": 2, + + "name": "One-click Kittens", + "description": "This extension demonstrates a 'browser action' with kittens.", + "version": "1.0", + + "browser_action": { + "default_icon": "icon.png", + "default_popup": "popup.html" + }, + "permissions": [ + "https://secure.flickr.com/" + ] +} diff --git a/ChromeExtensionExamples/BasicPopup/popup.html b/ChromeExtensionExamples/BasicPopup/popup.html new file mode 100644 index 0000000..f58540d --- /dev/null +++ b/ChromeExtensionExamples/BasicPopup/popup.html @@ -0,0 +1,31 @@ + + + + Getting Started Extension's Popup + + + + + + + + + diff --git a/ChromeExtensionExamples/BasicPopup/popup.js b/ChromeExtensionExamples/BasicPopup/popup.js new file mode 100644 index 0000000..bdbe548 --- /dev/null +++ b/ChromeExtensionExamples/BasicPopup/popup.js @@ -0,0 +1,83 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * Global variable containing the query we'd like to pass to Flickr. In this + * case, kittens! + * + * @type {string} + */ +var QUERY = 'kittens'; + +var kittenGenerator = { + /** + * Flickr URL that will give us lots and lots of whatever we're looking for. + * + * See http://www.flickr.com/services/api/flickr.photos.search.html for + * details about the construction of this URL. + * + * @type {string} + * @private + */ + searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' + + 'method=flickr.photos.search&' + + 'api_key=90485e931f687a9b9c2a66bf58a3861a&' + + 'text=' + encodeURIComponent(QUERY) + '&' + + 'safe_search=1&' + + 'content_type=1&' + + 'sort=interestingness-desc&' + + 'per_page=20', + + /** + * Sends an XHR GET request to grab photos of lots and lots of kittens. The + * XHR's 'onload' event is hooks up to the 'showPhotos_' method. + * + * @public + */ + requestKittens: function() { + var req = new XMLHttpRequest(); + req.open("GET", this.searchOnFlickr_, true); + req.onload = this.showPhotos_.bind(this); + req.send(null); + }, + + /** + * Handle the 'onload' event of our kitten XHR request, generated in + * 'requestKittens', by generating 'img' elements, and stuffing them into + * the document for display. + * + * @param {ProgressEvent} e The XHR ProgressEvent. + * @private + */ + showPhotos_: function (e) { + var kittens = e.target.responseXML.querySelectorAll('photo'); + for (var i = 0; i < kittens.length; i++) { + var img = document.createElement('img'); + img.src = this.constructKittenURL_(kittens[i]); + img.setAttribute('alt', kittens[i].getAttribute('title')); + document.body.appendChild(img); + } + }, + + /** + * Given a photo, construct a URL using the method outlined at + * http://www.flickr.com/services/api/misc.urlKittenl + * + * @param {DOMElement} A kitten. + * @return {string} The kitten's URL. + * @private + */ + constructKittenURL_: function (photo) { + return "http://farm" + photo.getAttribute("farm") + + ".static.flickr.com/" + photo.getAttribute("server") + + "/" + photo.getAttribute("id") + + "_" + photo.getAttribute("secret") + + "_s.jpg"; + } +}; + +// Run our kitten generation script as soon as the document's DOM is ready. +document.addEventListener('DOMContentLoaded', function () { + kittenGenerator.requestKittens(); +}); diff --git a/ChromeExtensionExamples/BasicPopup/readme.md b/ChromeExtensionExamples/BasicPopup/readme.md new file mode 100644 index 0000000..ba77dee --- /dev/null +++ b/ChromeExtensionExamples/BasicPopup/readme.md @@ -0,0 +1,7 @@ +1. Visit chrome://extensions in your browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox: The menu's icon is three horizontal bars.. and select Extensions under the Tools menu to get to the same place). + +2. Ensure that the Developer mode checkbox in the top right-hand corner is checked. + +3. Click Load unpacked extension… to pop up a file-selection dialog. + +4. Navigate to the directory in which your extension files live, and select it. diff --git a/ChromeExtensionExamples/extension/background.html b/ChromeExtensionExamples/extension/background.html new file mode 100755 index 0000000..7c8c9af --- /dev/null +++ b/ChromeExtensionExamples/extension/background.html @@ -0,0 +1,5 @@ +chrome.tabs.getSelected(null, function(tab) { + chrome.tabs.sendMessage(tab.id, {greeting: "hello"}, function(response) { + console.log(response.farewell); + }); +}); \ No newline at end of file diff --git a/ChromeExtensionExamples/extension/background.js b/ChromeExtensionExamples/extension/background.js new file mode 100644 index 0000000..e69de29 diff --git a/ChromeExtensionExamples/extension/contentscript.js b/ChromeExtensionExamples/extension/contentscript.js new file mode 100755 index 0000000..aad27b2 --- /dev/null +++ b/ChromeExtensionExamples/extension/contentscript.js @@ -0,0 +1,9 @@ +// add html overlay elts to page +// PEND: change this to load html file +var newdiv = document.createElement('div'); +newdiv.setAttribute('id','sabotage'); +var wordsdiv = document.createElement("div"); +wordsdiv.setAttribute('id', 'words'); +newdiv.appendChild(wordsdiv); +document.body.appendChild(newdiv); + diff --git a/ChromeExtensionExamples/extension/icon.png b/ChromeExtensionExamples/extension/icon.png new file mode 100755 index 0000000..0fe39b0 Binary files /dev/null and b/ChromeExtensionExamples/extension/icon.png differ diff --git a/ChromeExtensionExamples/extension/manifest.json b/ChromeExtensionExamples/extension/manifest.json new file mode 100755 index 0000000..7213fcc --- /dev/null +++ b/ChromeExtensionExamples/extension/manifest.json @@ -0,0 +1,27 @@ +{ + "manifest_version": 2, + + "name": "bg ext", + "description": "example background extension", + "version": "1.0", + + "permissions": ["tabs", "http://*/*", "https://*/*", "", "background"], + "content_scripts": [ + { + "matches": ["http://www.youtube.com/*"], + "js": ["contentscript.js"], + "css": ["style.css"] + } + ], + "background": { + "persistent": false, + "scripts": ["background.js"], + "html": ["background.html"] + }, + "web_accessible_resources": [], + "browser_action": { + "default_title": "hi", + "default_icon": "icon.png", + "default_popup": "popup.html" + } +} \ No newline at end of file diff --git a/ChromeExtensionExamples/extension/popup.html b/ChromeExtensionExamples/extension/popup.html new file mode 100755 index 0000000..ab7fa29 --- /dev/null +++ b/ChromeExtensionExamples/extension/popup.html @@ -0,0 +1,33 @@ + + + + Getting Started Extension's Popup + + + + + + + + hi hi + + + diff --git a/ChromeExtensionExamples/extension/popup.js b/ChromeExtensionExamples/extension/popup.js new file mode 100755 index 0000000..bdbe548 --- /dev/null +++ b/ChromeExtensionExamples/extension/popup.js @@ -0,0 +1,83 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * Global variable containing the query we'd like to pass to Flickr. In this + * case, kittens! + * + * @type {string} + */ +var QUERY = 'kittens'; + +var kittenGenerator = { + /** + * Flickr URL that will give us lots and lots of whatever we're looking for. + * + * See http://www.flickr.com/services/api/flickr.photos.search.html for + * details about the construction of this URL. + * + * @type {string} + * @private + */ + searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' + + 'method=flickr.photos.search&' + + 'api_key=90485e931f687a9b9c2a66bf58a3861a&' + + 'text=' + encodeURIComponent(QUERY) + '&' + + 'safe_search=1&' + + 'content_type=1&' + + 'sort=interestingness-desc&' + + 'per_page=20', + + /** + * Sends an XHR GET request to grab photos of lots and lots of kittens. The + * XHR's 'onload' event is hooks up to the 'showPhotos_' method. + * + * @public + */ + requestKittens: function() { + var req = new XMLHttpRequest(); + req.open("GET", this.searchOnFlickr_, true); + req.onload = this.showPhotos_.bind(this); + req.send(null); + }, + + /** + * Handle the 'onload' event of our kitten XHR request, generated in + * 'requestKittens', by generating 'img' elements, and stuffing them into + * the document for display. + * + * @param {ProgressEvent} e The XHR ProgressEvent. + * @private + */ + showPhotos_: function (e) { + var kittens = e.target.responseXML.querySelectorAll('photo'); + for (var i = 0; i < kittens.length; i++) { + var img = document.createElement('img'); + img.src = this.constructKittenURL_(kittens[i]); + img.setAttribute('alt', kittens[i].getAttribute('title')); + document.body.appendChild(img); + } + }, + + /** + * Given a photo, construct a URL using the method outlined at + * http://www.flickr.com/services/api/misc.urlKittenl + * + * @param {DOMElement} A kitten. + * @return {string} The kitten's URL. + * @private + */ + constructKittenURL_: function (photo) { + return "http://farm" + photo.getAttribute("farm") + + ".static.flickr.com/" + photo.getAttribute("server") + + "/" + photo.getAttribute("id") + + "_" + photo.getAttribute("secret") + + "_s.jpg"; + } +}; + +// Run our kitten generation script as soon as the document's DOM is ready. +document.addEventListener('DOMContentLoaded', function () { + kittenGenerator.requestKittens(); +}); diff --git a/ChromeExtensionExamples/extension/style.css b/ChromeExtensionExamples/extension/style.css new file mode 100755 index 0000000..54eb494 --- /dev/null +++ b/ChromeExtensionExamples/extension/style.css @@ -0,0 +1,14 @@ +#sabotage { + width: 100%; + height: 100%; + position: absolute; + top:0px; + left:0px; + background-color: gray; +} + +#words { + font-size: 34pt; + font-family: helvetica; + color: white; +} \ No newline at end of file diff --git a/ProcessingFBExamples/Example/Example.pde b/ProcessingFBExamples/Example/Example.pde new file mode 100644 index 0000000..9a1bea4 --- /dev/null +++ b/ProcessingFBExamples/Example/Example.pde @@ -0,0 +1,75 @@ +// 1. Go to developers.facebook.com/apps and click "Create New App". +// 2. + +import facebook4j.Facebook; +import facebook4j.FacebookFactory; + +import processing.net.*; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; + + +void setup() { + + String client_id = "167631416773261"; + String client_secret = "b9d3b8c809daeaaa07f5fcdc13de4010"; + String redirect_uri = "http://lauren-mccarthy.com/"; + + // init empty + String access_token = ""; + + try + { + String url = "https://graph.facebook.com/oauth/access_token?client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials,offline_access&redirect_uri="+redirect_uri; + DefaultHttpClient httpClient = new DefaultHttpClient(); + HttpPost httpPost = new HttpPost( url ); + + println( "executing request: " + httpPost.getRequestLine() ); + + HttpResponse response = httpClient.execute( httpPost ); + HttpEntity entity = response.getEntity(); + + println("----------------------------------------"); + println( response.getStatusLine() ); + println("----------------------------------------"); + + String content = EntityUtils.toString(entity); + String[] ind = content.split("access_token="); + if (ind.length > 1) { + access_token = ind[1]; + println("got access token: "+access_token); + } + EntityUtils.consume(entity); + httpClient.getConnectionManager().shutdown(); + + /* +// Client client = new Client(this, "127.0.0.1", 5204); + Client c = new Client(this, "https://graph.facebook.com", 80); // Connect to server on port 80 + c.write("GET /oauth/access_token?client_id=2710cdbc4e2fb5dd0bb9f2c9c1d5343a&grant_type=post HTTP/1.1\n"); // Use the HTTP "GET" command to ask for a Web page + + if (c.available() > 0) { // If there's incoming data from the client... + String data = c.readString(); // ...then grab it and print it + println(data); + } + */ + + println("using token "+access_token); + + Facebook facebook = new FacebookFactory().getInstance(); + facebook.setOAuthAppId(client_id, client_secret); + facebook.setOAuthPermissions("client_credentials"); + facebook.setOAuthAccessToken(new AccessToken(access_token, null)); + + facebook.postStatusMessage("Hello from P5."); + } + catch (Exception ex) { + println(ex); + } +} + +void draw() { +} + diff --git a/ProcessingFBExamples/Example/code/commons-codec-1.6.jar b/ProcessingFBExamples/Example/code/commons-codec-1.6.jar new file mode 100644 index 0000000..ee1bc49 Binary files /dev/null and b/ProcessingFBExamples/Example/code/commons-codec-1.6.jar differ diff --git a/ProcessingFBExamples/Example/code/commons-logging-1.1.3.jar b/ProcessingFBExamples/Example/code/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/ProcessingFBExamples/Example/code/commons-logging-1.1.3.jar differ diff --git a/ProcessingFBExamples/Example/code/facebook4j-core-2.0.0.jar b/ProcessingFBExamples/Example/code/facebook4j-core-2.0.0.jar new file mode 100644 index 0000000..33a2108 Binary files /dev/null and b/ProcessingFBExamples/Example/code/facebook4j-core-2.0.0.jar differ diff --git a/ProcessingFBExamples/Example/code/fluent-hc-4.3.jar b/ProcessingFBExamples/Example/code/fluent-hc-4.3.jar new file mode 100644 index 0000000..73c49d9 Binary files /dev/null and b/ProcessingFBExamples/Example/code/fluent-hc-4.3.jar differ diff --git a/ProcessingFBExamples/Example/code/httpclient-4.3.jar b/ProcessingFBExamples/Example/code/httpclient-4.3.jar new file mode 100644 index 0000000..5c446f0 Binary files /dev/null and b/ProcessingFBExamples/Example/code/httpclient-4.3.jar differ diff --git a/ProcessingFBExamples/Example/code/httpclient-cache-4.3.jar b/ProcessingFBExamples/Example/code/httpclient-cache-4.3.jar new file mode 100644 index 0000000..ba489a4 Binary files /dev/null and b/ProcessingFBExamples/Example/code/httpclient-cache-4.3.jar differ diff --git a/ProcessingFBExamples/Example/code/httpcore-4.3.jar b/ProcessingFBExamples/Example/code/httpcore-4.3.jar new file mode 100644 index 0000000..e5da457 Binary files /dev/null and b/ProcessingFBExamples/Example/code/httpcore-4.3.jar differ diff --git a/ProcessingFBExamples/Example/code/httpmime-4.3.jar b/ProcessingFBExamples/Example/code/httpmime-4.3.jar new file mode 100644 index 0000000..55dd8ae Binary files /dev/null and b/ProcessingFBExamples/Example/code/httpmime-4.3.jar differ diff --git a/ProcessingFBExamples/Example2/Example2.pde b/ProcessingFBExamples/Example2/Example2.pde new file mode 100644 index 0000000..063a284 --- /dev/null +++ b/ProcessingFBExamples/Example2/Example2.pde @@ -0,0 +1,58 @@ +// 1. Go to developers.facebook.com/apps and click "Create New App". +// 2. + +import processing.net.*; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; + + +void setup() { + + String client_id = "167631416773261"; + String client_secret = "b9d3b8c809daeaaa07f5fcdc13de4010"; + + try + { + String url = "https://graph.facebook.com/me/feed?access_token="+client_id+"%7C"+client_secret; + + println(url); + DefaultHttpClient httpClient = new DefaultHttpClient(); + HttpPost httpPost = new HttpPost( url ); + + println( "executing request: " + httpPost.getRequestLine() ); + + HttpResponse response = httpClient.execute( httpPost ); + HttpEntity entity = response.getEntity(); + + println("----------------------------------------"); + println( response.getStatusLine() ); + println("----------------------------------------"); + + String content = EntityUtils.toString(entity); + println(content); + EntityUtils.consume(entity); + httpClient.getConnectionManager().shutdown(); + + + /* +// Client client = new Client(this, "127.0.0.1", 5204); + Client c = new Client(this, "https://graph.facebook.com", 80); // Connect to server on port 80 + c.write("GET /oauth/access_token?client_id=2710cdbc4e2fb5dd0bb9f2c9c1d5343a&grant_type=post HTTP/1.1\n"); // Use the HTTP "GET" command to ask for a Web page + + if (c.available() > 0) { // If there's incoming data from the client... + String data = c.readString(); // ...then grab it and print it + println(data); + } + */ + } + catch (Exception ex) { + println(ex); + } +} + +void draw() { +} + diff --git a/ProcessingFBExamples/Example2/code/commons-codec-1.6.jar b/ProcessingFBExamples/Example2/code/commons-codec-1.6.jar new file mode 100644 index 0000000..ee1bc49 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/commons-codec-1.6.jar differ diff --git a/ProcessingFBExamples/Example2/code/commons-logging-1.1.3.jar b/ProcessingFBExamples/Example2/code/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/commons-logging-1.1.3.jar differ diff --git a/ProcessingFBExamples/Example2/code/facebook4j-core-2.0.0.jar b/ProcessingFBExamples/Example2/code/facebook4j-core-2.0.0.jar new file mode 100644 index 0000000..33a2108 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/facebook4j-core-2.0.0.jar differ diff --git a/ProcessingFBExamples/Example2/code/fluent-hc-4.3.jar b/ProcessingFBExamples/Example2/code/fluent-hc-4.3.jar new file mode 100644 index 0000000..73c49d9 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/fluent-hc-4.3.jar differ diff --git a/ProcessingFBExamples/Example2/code/httpclient-4.3.jar b/ProcessingFBExamples/Example2/code/httpclient-4.3.jar new file mode 100644 index 0000000..5c446f0 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/httpclient-4.3.jar differ diff --git a/ProcessingFBExamples/Example2/code/httpclient-cache-4.3.jar b/ProcessingFBExamples/Example2/code/httpclient-cache-4.3.jar new file mode 100644 index 0000000..ba489a4 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/httpclient-cache-4.3.jar differ diff --git a/ProcessingFBExamples/Example2/code/httpcore-4.3.jar b/ProcessingFBExamples/Example2/code/httpcore-4.3.jar new file mode 100644 index 0000000..e5da457 Binary files /dev/null and b/ProcessingFBExamples/Example2/code/httpcore-4.3.jar differ diff --git a/ProcessingFBExamples/Example2/code/httpmime-4.3.jar b/ProcessingFBExamples/Example2/code/httpmime-4.3.jar new file mode 100644 index 0000000..55dd8ae Binary files /dev/null and b/ProcessingFBExamples/Example2/code/httpmime-4.3.jar differ diff --git a/tweetscrape/index.php b/tweetscrape/index.php index 5325a98..8807baf 100755 --- a/tweetscrape/index.php +++ b/tweetscrape/index.php @@ -59,21 +59,44 @@ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET); // If method is set change API call made. Test is called by default. - $content = $connection->get('search/tweets', array('q' => '#socialhacking', 'count' => '100', 'result_type' => 'recent')); - $json = json_decode($content, true); - if($json == null || !array_key_exists("statuses", $json)) { - echo "Error retrieving results from Twitter."; - return; + + $students = array( + "hanbyul-here", + "juyoungp88", + "atraciuk", + "m1keall1son", + "lawn___mower", + "carljamilkowski", + "m4ckaroni", + "harryhow", + "iamsukim", + "gal_sasson", + "taranagupta", + "dd_yj", + "noterrain", + "nyuaesthetic" + ); + + + $statuses = array(); + foreach($students as $u) { + $content = $connection->get('statuses/user_timeline', array('screen_name' => $u, 'count' => '200', 'include_rts' => 'false')); + $json = json_decode($content, true); + foreach($json as $status) { + if(stristr($status['text'], '#socialhacking')) { + $statuses[] = $status; + } + } } + if(file_exists("db.json")) { $db = json_decode(file_get_contents("db.json"), true); } else { $db = array(); } - $statuses = $json["statuses"]; foreach($statuses as $newStatus) { $exists = false; foreach($db as $oldStatus) { @@ -110,7 +133,7 @@ ?>