1.0.6 • Published 9 years ago
tpr-sdk v1.0.6
Thirdpresence-javascript-sdk
Javascript SDK for Thirdpresence Platform
//Initialize the SDK, true for https, false for http
tprsdk.init(true);
tprsdk.doLogin("user", "pass", function(data){ //login
if (!data.errorresponse){
tprsdk.setSession(data.session_id); //Set the session id
tprsdk.getAds({ success: function(response){
console.log(response) //Print out all your ads
}, error: function(response){
console.log(response)
}});
} else {
console.log(data.message) //Something went wrong
}
},function(data){
console.log(data); //in case of error
});
//Include jquery, crypto-js and TPR SDK.
<script src="crypto-js.js"></script> //Located in: node_modules/tpr-sdk/node_modules/crypto-js/
<script src="jquery.min.js"></script> //Located in: node_modules/tpr-sdk/node_modules/jquery/dist/
<script src="thirdpresence-sdk.js"></script> //located in: node_modules/tpr-sdk/
<script>
var tprsdk = new TPR(); //create new TPR object
tprsdk.init(true); // initialize with https (true) or http(false)
//Do not hardcode user and password, get these from somewhere safe.
tprsdk.doLogin("[user]", "[password]]", function(data){
if (data.responseText=="success"){
tprsdk.setSession(data.responseObject.session_id); //Store this somewhere safe
//query your ads
tprsdk.getAds({
success:function (data){
console.log(data.responseObject); //Get an object containing your ads and use console.log to print them out.
},error: function(data){
console.log("Failed: "+data.responseObject.message);
}});
}
}, function(data){
console.log('login failed: '+data.responseObject.message);
});
</script>