Skip to content

Commit

Permalink
Merge pull request #4 from alexadkins/master
Browse files Browse the repository at this point in the history
Added PeerIndex Demo App
  • Loading branch information
mansilladev committed Jul 13, 2013
2 parents b24c150 + 51f1b06 commit ddfa80e
Show file tree
Hide file tree
Showing 32 changed files with 2,702 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mashery.klout/3.4.0/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ standard web languages (HTML5, CSS, and JavaScript).

FEATURES
==================================================================
Uses Klout's API to find Klout score based on your Twitter handle (Supports up to three comma separated handles)
Uses Klout's API to find Klout score based on your Twitter handle.



Expand Down
96 changes: 96 additions & 0 deletions mashery.peerindex/3.4.0/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
PEERINDEX API DEMO APP
==================================================================
Created lovingly for the developer community by Mashery.

http://www.mashery.com

http://developer.mashery.com


SYNOPSIS
==================================================================
This demo App provides a way to see the PeerIndex API in action.
It's built using Intel's Cross Platform Development Kit (XDK)
that lets you create mobile apps for smartphones and tablets using
standard web languages (HTML5, CSS, and JavaScript).



FEATURES
==================================================================
Uses PeerIndex's API to find PeerIndex score based on your Twitter handle.



GETTING STARTED
==================================================================
You will need the following to get started -

1. Intel's XDK. Free Download - http://xdk-software.intel.com/
2. A PeerIndex API key (Register at https://developers.peerindex.com/member/register).



OBTAINING THE API KEY
==================================================================
Before you can begin using this app, you will need to get an API key
from PeerIndex at https://developers.peerindex.com/member/register. This will also
give you a Single Sign-On Mashery ID with access to hundreds of other APIs.


SETTING UP THE API KEY IN THIS APP
==================================================================
Once you have obtained your API key, assign the API key to the
variable api_key on line 1 of the file PeerIndex.js, like so -

<pre>
var api_key ='your_api_key_here';
</pre>

If your API Key surpasses the Rate Limit, contact api@peerindex.com to discuss higher usage levels.


ABOUT THE PEERINDEX API
==================================================================

PeerIndex API allows developers access to the following information -

1. PeerIndex Score - A relative measure of an actor's online influence (a normalised score of range 0-100, where 0 is the lowest and 100 is the highest). For more information on the PeerIndex score, take a look at the <a href="http://help.peerindex.com/">FAQ section on peerindex.com</a>
2. Activity (score) - Normalised 0 to 100 score representing the frequency of which the actor shares content on the social web
3. Authority (score) - Normalised 0 to 100 score representing the degree to which the actor's audience recognises them as a thought leader
4. Audience (score) - Normalised 0 to 100 score representing the effective size of the audience the actor's messages reach
5. Topic score - Topic scores are normalised between 0 and 100 (A topic score of 0 indicates an actor has no recognised interest or authority in the topic. A score of 100 would indicate the actor is likely to be a world leading authority on the topic)



Learn more about the PeerIndex API at https://developers.peerindex.com/


PEERINDEX API DOCUMENTATION
==================================================================
To learn more about the data set provided by PeerIndex's API, you can read
through the API documentation at https://developers.peerindex.com/io-docs


ABOUT THE MASHERY API NETWORK
==================================================================
The Mashery API Network (http://developer.mashery.com) is an open
data commons of over 50 RESTful APIs that developers can access
with their Mashery ID.

Mashery is the world's leading API management service provider, helping
companies provide the best API experience for developers, as well as
the most advanced API management and reporting tools to our clients.


EXPLORE MORE APIS
==================================================================
Check out Mashery's API Network at http://developer.mashery.com/apis
to explore other awesome APIs including NY Times, Klout, USA TODAY,
Rotten Tomatoes, Best Buy, Hoovers, Edmunds, Netflix, Rdio and many more.


SUPPORT
==================================================================
If you have any questions or need any help obtaining an API key,
you can reach out to us at: developer-relations@mashery.com
186 changes: 186 additions & 0 deletions mashery.peerindex/3.4.0/_appMobi/xhr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/* xhr.js
* This overrides the XMLHTTPRequest object to allow cross domain ajax requests
*/
(function () {
document.addEventListener("appMobi.device.remote.data", getRemoteExtCB, false);
var ajaxCallbacks = [];

function getRemoteExtCB(obj) {
if (ajaxCallbacks.length > 0 && ajaxCallbacks[obj.id]) {
ajaxCallbacks[obj.id](obj);
}
}

XMLHttpRequest_Native = XMLHttpRequest;
XMLHttpRequest.Extension = new Object;

XMLHttpRequest.Extension.addObject = function (object) {
uniqueId = Math.floor(Math.random() * 99999999);
object.uniqueId = uniqueId;
this[uniqueId] = object;
return uniqueId;
}

XMLHttpRequest.Extension.sendXMLHTTP = function (data) {
var myparams = new AppMobi.Device.RemoteDataParameters();
for (var j in data.headers) {
myparams.addHeader(j, data.headers[j]);
}

myparams.url = data.requestData.URL;
myparams.id = data.uniqueId;
myparams.method = data.requestData.method
myparams.body = data.body;
try{
if(typeof myparams.body=="object"){
myparams.body=JSON.stringify(myparams.body);
}
ajaxCallbacks[myparams.id] = this.handleResponseData;
AppMobi.device.getRemoteDataExt(myparams);
}
catch(e){}
}

XMLHttpRequest.Extension.handleResponseData = function (object) {

var XMLObj = XMLHttpRequest.Extension[object.id];
//EMULATED "HEADERS RECEIVED" CHANGES
var newHeaders = [];
for (var j in object.extras.headers) {
newHeaders[j.toLowerCase()] = object.extras.headers[j]; //jQuery looks for lowercase
newHeaders[j] = object.extras.headers[j];
}
XMLObj.responseData.headers = newHeaders;
XMLObj.readyState = XMLObj.HEADERS_RECEIVED;
if (typeof XMLObj.onreadystatechange == 'function') XMLObj.onreadystatechange();

XMLObj.readyState = XMLObj.LOADING;
if (typeof XMLObj.onreadystatechange == 'function') XMLObj.onreadystatechange();

XMLObj.response = object.response;
XMLObj.status = object.extras.status;
XMLObj.responseText = object.response;
XMLObj.responseXML = object.response;
XMLObj.readyState = XMLObj.DONE;

if (typeof XMLObj.onreadystatechange == 'function') XMLObj.onreadystatechange();
}


// XMLHTTP REDEFINE
//=======================================================================================================================
//DEFINE "CONSTANTS" FOR CONSTRUCTOR
XMLHttpRequest.UNSENT = 0; //const
XMLHttpRequest.OPENED = 1; //const
XMLHttpRequest.HEADERS_RECEIVED = 2; //const
XMLHttpRequest.LOADING = 3; //const
XMLHttpRequest.DONE = 4; //const

//DEFINE "CONSTANTS" PROTOTYPE
XMLHttpRequest.prototype.UNSENT = 0; //const
XMLHttpRequest.prototype.OPENED = 1; //const
XMLHttpRequest.prototype.HEADERS_RECEIVED = 2; //const
XMLHttpRequest.prototype.LOADING = 3; //const
XMLHttpRequest.prototype.DONE = 4; //const
//XMLHttpRequest = {readyState:0 };
XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.readyState = 0;
XMLHttpRequest.prototype.onreadystatechange;
XMLHttpRequest.prototype.headers = {};
XMLHttpRequest.prototype.body = "";



XMLHttpRequest.prototype.requestData = {
'method': null,
'URL': null,
'asynchronous': true,
'username': null,
'password': null,
'headers': null
};
XMLHttpRequest.prototype.responseData = {
'headers': null
};


XMLHttpRequest.prototype.abort = function abort() {};
XMLHttpRequest.prototype.addEventListener = function addEventListener() {};
XMLHttpRequest.prototype.constructor = function XMLHttpRequest() {};
XMLHttpRequest.prototype.dispatchEvent = function dispatchEvent() {};

XMLHttpRequest.prototype.getAllResponseHeaders = function getAllResponseHeaders() {
if (this.readyState == this.OPENED || this.readyState == this.UNSENT) return "";
else {
return this.responseData.headers;
}
};

XMLHttpRequest.prototype.getResponseHeader = function getResponseHeader(header) {
return this.responseData.headers && this.responseData.headers[header] ? this.responseData.headers[header] : "";
};

XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
//supported methods: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE, or TRACK
/* Empty the list of author request headers.
Set the request method to method.
Set the request URL to url.
Set the request username to temp user.
Set the request password to temp password.
Set the asynchronous flag to the value of async.
*/
this.requestData.method = method;
this.requestData.URL = url;
this.requestData.asynchronous = async;
this.requestData.user = user;
this.requestData.password = password;
this.readyState = this.OPENED;
if (typeof this.onreadystatechange == 'function') this.onreadystatechange();

}

XMLHttpRequest.prototype.overrideMimeType = function overrideMimeType() {};
XMLHttpRequest.prototype.removeEventListener = function removeEventListener() {};

XMLHttpRequest.prototype.send = function send(data) {
this.body = data;
if(this.requestData.asynchronous===false)
{
throw ("Synchronous XMLHtppRequest calls are not allowed. Please change your request to be asynchronous");
return;
}
XMLHttpRequest.Extension.sendXMLHTTP(this);
};

XMLHttpRequest.prototype.setRequestHeader = function setRequestHeader(header, value) {
this.headers[header] = value;
};


function XMLHttpRequest() {
XMLHttpRequest.Extension.addObject(this);
this.onabort = null;
this.onerror = null;
this.onload = null;
this.onloadstart = null;
this.onprogress = null;
this.onreadystatechange = null;
this.readyState = 0;
this.response = "";
this.responseText = "";
this.responseType = "";
this.responseXML = null;
this.status = 0;
this.statusText = "";
this.withCredentials = false;
this.requestData = {
'method': null,
'URL': null,
'asynchronous': null,
'username': null,
'password': null,
'headers': null
};
}
window.XMLHttpRequest = XMLHttpRequest;
})();
Loading

0 comments on commit ddfa80e

Please sign in to comment.