Software Archive
Read-only legacy content
17061 Discussions

Simple Web Service

Marco_S_
Beginner
503 Views

Hi all,

I need to create a simple custom web service, but I'm a newbie with XDK and I need some help.

I need to call

https://assistenza.octaviangaming.com/renting/api?mobile_num=12345678

I create 3 files :

apiconfig.json

{
  "renting_api": {
    "name": "OctavianGaming",
    "description": "Octy renting REST API",
    "dashboardUrl": "https://assistenza.octaviangaming.com/renting/api"
  }
}

renting_api.js

(function (params) {
  var exports = {};
 
  /* Data Feed Function */
  exports.default = function (program) {
   
    var url = 'https://assistenza.octaviangaming.com/renting/api/?mobile_num='+ params.mobile_num;
    return $.ajax({url: url});
  };

renting_api.json  

{
"endpoints": [
  {
    "name": "EnabledMobileNum",
    "dashboardUrl": "https://assistenza.octaviangaming.com/",
    "methods": [
      {
        "MethodName": "default",
        "Synopsis": "Grabs information from the A1 data set",
        "parameters": [
          {
            "Name": "mobile_num",
            "Required": "Y",
            "Default": "",
            "Type": "string",
            "Description": "Mobile Number to check if is enabled"
          }
        ]
      }
    ]
  }
]
}

  return exports;
})

I want to call it from a js, what I have to include in .js file?

Thanks In Advance

 

0 Kudos
6 Replies
Amrita_C_Intel
Employee
503 Views

Hi,

You can refer to below provided video

software.intel.com/en-us/html5/videos/integrating-a-new-service

 

0 Kudos
Marco_S_
Beginner
503 Views

Below the solution:

{
  "renting_api": {
    "name": "OctavianGaming",
    "description": "Renting Rest API",
    "dashboardUrl": "https://assistenza.octaviangaming.com"
  }
}

(function (credentials, helpers) {
  var exports = {};
   
  exports.CheckMobileEnabling = function(params) {
    var url = 'https://assistenza.octaviangaming.com/renting/api/?mobile_num=' + params.mobile_num;
    //if (params) url = url + '?' + $.param(params);
    return $.ajax({url: url, type: 'GET'});
  };
 
  return exports;
})

{
"endpoints": [
  {
    "name": "RentingApi",
    "dashboardUrl": "https://assistenza.octaviangaming.com",
    "methods": [
      {
        "MethodName": "CheckMobileEnabling",
        "Synopsis": "CheckMobileEnabling",
        "parameters": [
          {
            "Name": "mobile_num",
            "Required": "Y",
            "Default": "",
            "Type": "string",
            "Description": "Mobile Number parameter."
          }
        ]
      }
    ]
  }
]
}

0 Kudos
Marco_S_
Beginner
503 Views

Dear Amrita,

  the Intel XDK is a amazing tools, but, the documentation is quite poor. Follow a video is quite heavy, better a simple and clear Examples.

Like this :

http://qnimate.com/post-series/intel-xdk-complete-training/

In the official Intel support pages, in my opinon, there are too written words.

Regards

0 Kudos
Amrita_C_Intel
Employee
503 Views

I am glad it is working now. Thank You for your feedback, I will definitely pass it to the development team.

0 Kudos
John_P_6
Beginner
503 Views

I am looking for something similar to above . I would like to create a web service to connect to a MySQL external database / with authentication  and store authentication  in local mobile device . All the samples of the videos show existing Web Services . I would like to create my own . Do you have a sample video of how to create your own web service. on Intel XDK ?

Note this video sample uses an existing web service . software.intel.com/en-us/html5/videos/integrating-a-new-service

0 Kudos
Reply