Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*function loadJSON()
- {
- //Damit der jQuerry auf das API zugreifen kann muss CORS auf dem server den zugang gewährleisten, für Wordpress gibt
- //es wp-cors. https://wordpress.org/plugins/wp-cors/
- $.getJSON('http://diego.graphics/api/info/', function(data) {
- console.log(data);
- console.log(data["json_api_version"]);
- });
- }*/
- var wordpress_api = new function() {
- this.api_url = "http://example.de/api";
- this.api_key = "";
- this.api_version = "";
- this.api_status = "";
- this.api_controllers = array();
- this.username = "";
- this.password = "";
- this.cookie = "";
- this.nonce = "";
- //Setzt die API daten.
- this.setAPI = function (api_url, api_key) {
- this.api_url = api_url;
- this.apu_key = api_key;
- return true;
- };
- //Setzt den Logincookie des Benutzers
- this.setCookie = function (cookie) {
- this.cookie = cookie;
- return true;
- }
- //Setzt den aktuellen nonce.
- this.setNonce = function (nonce) {
- this.nonce = nonce;
- return true;
- }
- //Setzt die API Infos
- this.setInfo = function () {
- $.getJSON('http://diego.graphics/api/info/', function(data) {
- this.api_version = data["json_api_version"];
- this.api_controllers = data["controllers"];
- if(data["status"] == "ok"){
- this.api_status = true;
- } else {
- this.api_status = false;
- }
- });
- return true;
- }
- this.getInfo = function (index) {
- switch (index) {
- case "version":
- return this.api_version;
- break;
- case "controllers":
- return this.api_controllers;
- break;
- case "status":
- return this.api_status;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement