Skip to content

Instantly share code, notes, and snippets.

@sampsonbryce
Created July 29, 2016 01:30
Show Gist options
  • Save sampsonbryce/913149a6743987d780363518aad9ec2f to your computer and use it in GitHub Desktop.
Save sampsonbryce/913149a6743987d780363518aad9ec2f to your computer and use it in GitHub Desktop.
An ajax to access DataSift API
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example App</title>
</head>
<body>
{{{body}}}
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script>
// directly modified from curl at http://lp.datasift.com/rs/068-LBF-492/images/Facebook-topic-data-trial-Quickstart.pdf?mkt_tok=eyJpIjoiT1RCaVl6aGxPRFV6TVRoayIsInQiOiJGajNuVzYzTHdYVWVcL0dHZ0xPb2hkMW80U0NvOUxUeURlRGJ1K1hNb1YwcW5zd1hmTCtuY0EyNGFwajRROURNdEV6eTRwMXRETVwvRzlJb3k4OTMzaTJkVVJrU0NMUGtVcEo3dzRiV0JYM2ljPSJ9
$.ajax({
url: 'https://pylonsandbox.datasift.com/v1.3/pylon/analyze',
data: '{"id":"proper_id","parameters":{"analysis_type":"freqDist","parameters":{"threshold":2,"target":"fb.author.gender"}}}', //except with proper id from entertainment index guide
contentType: 'application/json',
headers: {
Authorization: "<username:api_key>", //expect any random username I can think of and the API key provided by datasift
},
success: function(data, status, request){
console.log('success');
},
error: function(request, status, error){
console.log('error', status, error);
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment