Skip to content

Instantly share code, notes, and snippets.

Last active March 10, 2017 19:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sunnygleason/5b604fa436af8eba644102858bead22d to your computer and use it in GitHub Desktop.
PubNub Content Analysis UI w/ Diffbot
<!doctype html>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="//" />
<link rel="stylesheet" href="" />
<div class="container" ng-app="PubNubAngularApp" ng-controller="MyTextCtrl">
NOTE: make sure to update the PubNub keys below with your keys,
and ensure that the text analysis BLOCK is configured properly!
<h3>MyText Content Analysis</h3>
<input ng-model="toSend" placeholder="type URL here" />
<input type="button" ng-click="publish()" value="Send!" />
<br /><br />
<li ng-repeat="message in messages track by $index">
<a href="{{message.url}}">{{message.diffbotResponse.title}}</a> by {{message.diffbotResponse.objects[0].author}}
<br />
url: <a href="{{message.url}}">{{message.url}}</a>
<br />
type: {{message.diffbotResponse.type}}; language: {{message.diffbotResponse.humanLanguage}}
<br />
<span style="color:gray" ng-repeat="tag in message.diffbotResponse.objects[0].tags track by $index">{{tag.label}}={{tag.score}};&nbsp;</span>
angular.module('PubNubAngularApp', ["pubnub.angular.service"])
.controller('MyTextCtrl', function($rootScope, $scope, Pubnub) {
$scope.messages = [];
$ = 'diffbot-channel';
if (!$rootScope.initialized) {
publishKey: 'YOUR_PUB_KEY',
subscribeKey: 'YOUR_SUB_KEY',
$rootScope.initialized = true;
var msgCallback = function(payload) {
$scope.$apply(function() {
$scope.publish = function() {
channel: $,
message: {url:$scope.toSend}
$scope.toSend = "";
Pubnub.subscribe({ channels: [$] });
Pubnub.addListener({ message: msgCallback });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment