Skip to content

Instantly share code, notes, and snippets.

View dugjason's full-sized avatar
:octocat:

Jason Dugdale dugjason

:octocat:
View GitHub Profile
{
"retweeted": false,
"text": "Photo Organization Service Everpix Launches Public Beta http://t.co/2WQKLro8",
"id_str": "152781555297820672",
"source": "<a href=\"http://www.alphonsolabs.com/\" rel=\"nofollow\">Pulse News</a>",
"entities": {
"hashtags": [],
"urls": [
{
"expanded_url": "http://feedproxy.google.com/~r/Techcrunch/~3/svLQS-Ayumk/",
@dugjason
dugjason / TwitterJSONOutputExample-UserSuspendMessage.json
Created March 16, 2012 14:27
Twitter JSON Output Example - user_suspend Message
{
"interaction": {
"id": "1e16ebc90331a780e0748d58940628be",
"type": "twitter",
"created_at": "Thu, 15 Mar 2012 16:33:15 +0000",
"author": {
"id": 15005238
}
},
"twitter": {
@dugjason
dugjason / DS_PAYG_Balance.json
Created June 7, 2012 16:01
DataSift 'Pay As You Go' Balance API call
{
"balance": {
"credit": 52.63,
"plan": "payg"
}
}
@dugjason
dugjason / DS_Subscription_Balance.json
Created June 7, 2012 16:03
DataSift 'Subscription' Balance API call
{
"balance": {
"remaining_dpus": 84459.1,
"cost": 773.23,
"plan": "Silver"
}
}
@dugjason
dugjason / ReadJSONFile.php
Created June 18, 2012 12:00
Simple PHP script to read a DataSift JSON export file line-by-line
<?php
$filename = dirname(__FILE__) . '/part-r-00000.json';
$filehandle = fopen($filename, 'r');
if ($filehandle) {
while (($interaction = fgets($filehandle)) !== false) {
// Set $interaction as the full JSON interaction, ready for processing.
$interaction = json_decode($interaction, true);
@dugjason
dugjason / DS_No-Auth.json
Created July 26, 2012 15:19
DataSift Streaming API error message indicating that your username or API key is missing from your API request
{"status":"failure","message":"A username and API key are both required"}
@dugjason
dugjason / getUsage.java
Created July 30, 2012 11:49
Short Java example using the Java API client to get your recent API usage stats
/**
* This example returns your stream usage for the last hour. You can edit the
* usage period by passing "hour" or "day" in the getUsage() method.
*/
package org.datasift.examples;
import org.datasift.*;
/**
* @author MediaSift
@dugjason
dugjason / test.json
Created August 16, 2012 09:48
Testing Gist
{"interaction":{"author":{"avatar":"http:\/\/a0.twimg.com\/profile_images\/1615759403\/powell_HS2_normal.jpg","id":402126179,"link":"http:\/\/twitter.com\/jeffpowell_Mail","name":"Jeff Powell","username":"jeffpowell_Mail"},"content":"RT @Kropotkin_alias: @jeffpowell_Mail If one of our Olympic heroes was found to have failed drug test in 6 months time same decision wou ...","created_at":"Tue, 14 Aug 2012 12:47:15 +0000","id":"1e1e60e2c994ab80e07424eac53e3bc8","link":"http:\/\/twitter.com\/jeffpowell_Mail\/statuses\/235356913284567041","source":"web","type":"twitter"},"klout":{"amplification":13,"network":32.22,"score":51,"topics":["john terry","racism","adidas","san antonio spurs","rafael nadal"],"true_reach":3256},"language":{"confidence":100,"tag":"en"},"salience":{"content":{"sentiment":-7}},"twitter":{"id":"235356913284567041","retweet":{"count":1,"created_at":"Tue, 14 Aug 2012 12:47:15 +0000","id":"235356913284567041","mentions":["jeffpowell_Mail"],"source":"web","text":"@jeffpowell_Mail If one of our Oly
@dugjason
dugjason / ReadDataSiftJSON.php
Created September 17, 2012 10:50
Reading a DataSift JSON file with PHP
<?php
$filename = dirname(__FILE__) . '/filename.json';
$filehandle = fopen($filename, 'r');
if ($filehandle) {
while (($interaction = fgets($filehandle, 4096)) !== false) {
$interaction = json_decode($interaction, true);
$total_processed++;
if (isset($interaction['twitter']['id'])) {
curl -X POST 'https://api.datasift.com/push/validate' \
-d 'output_type=s3' \
-d 'output_params.acl=private' \
-d 'output_params.bucket=BUCKETNAME' \
-d 'output_params.directory=DIRECTORYNAME' \
-d 'output_params.delivery_frequency=60' \
-d 'output_params.auth.access_key=ACCESSKEY' \
-d 'output_params.auth.secret_key=SECRETKEY' \
-H 'Auth: DATASIFT_USERNAME:DATASIFT_APIKEY'