How to Integrate JSON API from website

I have been assigned to integrate API for my client website. This API is provided by vision6.com.au. There is no much information avialble on their website. Can anyone give me one example which will contact vision6 database and add a contact from our website developed using jquery and php.

Here is the way I am trying

var newVal = {
    "id": 1,
    "method": "addUser",
    "params": [
        "APIKEY",
        "123456",
        {
            "username"     : "username_123",
            "password"     : "123456abc",
            "first_name"   : "First Name",
            "last_name"    : "Last Name",
            "email"        : "example@example.com",
            "mobile"       : "0412312312",
            "phone"        : "56565656",
            "fax"          : "57575757",
            "position"     : "Manager",
            "is_read_only" : true,
            "timezone"     : "Australia/Brisbane",
            "email_user"   : true,
            "is_confirmed" : true
        }
    ]
};

$.ajax({
    url: 'http://www.vision6.com.au/api/jsonrpcserver.php?version=3.0',  
    type: 'POST',
    beforeSend: function(){alert('sending');},
    data: newVal,
    //dataType: 'json',
    //data: JSON.stringify(newVal),
    //contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    //async: false,
    success: function(msg) { alert(msg);

    }

});

This is what I have taken from their documentation developers.vision6.com.au

You will need to download a jsonRPCClient.php and include it in your php file. From my dealings with the Vision6 API, its not very comprehensive and doesn't make much sense until you start getting into it more. Unfortunately, they aren't very helpful in getting you started.

My code to get you started

include 'includes/jsonRPCClient.php';    
$list_id = 1234;
$url = "http://www.vision6.com.au/api/jsonrpcserver.php?version=3.0";   
$apikey = 'YOURAPIKEYHERE'
$api = new JsonRpcClient($url);
    $contact = array();
    $contact[] = array(
         'First Name' => "John",
         'Email' => "sample@email.com"      
    );

$returnID = $api->addContacts($apikey, $list_id, $contact);

the most important change I found was

 $api->addContacts($apikey, $list_id, $contact); 

All methods using the API follow this structure

 $api ->APIMethod($apikey, $OtherRequiredFields/Arrays);    

API stands for Application Program Interface, which can be defined as a set of methods of communication between various software components. In other words, an API allows software to communicate with another software. We'll be focusing specifically on Web APIs, which allow a web server to interact with third-party software.

For those who wants to integrate using Ruby, I've created a gist with a simple code:

require 'httparty'

url = 'http://www.vision6.com.au/api/jsonrpcserver.php?version=3.0'
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

JSON.parse(HTTParty.post(url, headers: { 'Content-Type' => 'application/json' }, body: JSON.dump({
  'method' => 'getSessionInfo', 'params' => [api_key]
})))

JSON.parse(HTTParty.post(url, headers: { 'Content-Type' => 'application/json' }, body: JSON.dump({
  'method' => 'searchLists', 'params' => [api_key]
})))

list_id = 123456
JSON.parse(HTTParty.post(url, headers: { 'Content-Type' => 'application/json' }, body: JSON.dump({
  'method' => 'addContacts', 'params' => [api_key, list_id, [{ 'First Name' => 'Foo', 'Last Name' => 'Bar', 'Email' => 'foo@bar.com' }]]
})))

Once the data is returned from the API and parsed, we can convert it to a Redux-friendly format with json-api-normalizer and forward it to the Redux actions. Note: This code was copied and pasted from a real-world Redux instance, with small adjustments to add json-api-normalizer. Now you can see that integration with json-api-normalizer is

I suggest to follow their documentation

http://developers.vision6.com.au/3.0/guide/getting-started

Documentation mentions a client library to access their JSON-RPC. Download it, create a free account and generate a working snippet of PHP code from their examples. It also seems to contain a lot of insights and examples. I am just quoting PHP code for addbatch

// setup vars
$list_id01     = 123;
$list_id02     = 456;
$message_id    = 111;
$batch_details = array
(array
  ('list_id'      => $list_id01,
  'type'         => 'list',       // all Contacts in List 123
  'time'         => 'send,        // populate Batch time of send
  )
array
  ('list_id'      => $list_id02,
  'type'         => 'contact',     // send to contact_list, next
  'contact_list' => array(2),array(17),array(18),
  'time'         => 'send,        // populate Batch time of send
));
$queue_id = $api->invokeMethod('addBatch', $message_id, $batch_details,
time() + (24*3600), true);

Once you produce a snippet of code that does an authorization request and a simple action, but DOES NOT behave as you expected you should update your question on SO. I.e. you should post the snippet and the results that you get vs. the results that you expect to get. That might really help to tackle the problem.

I would also recommend to contact support of the service directly.

PS

Unless you will be able to ask a question in form that would be potentially useful to other users, It would be very difficult to get an answer that you seek. Otherwise your question can be qualified as too localized.

In this blog, we are going to discuss how to authenticate Nodejs API with JSON Web Tokens. But before going further, let's break it down what is JSON Web Token. JWT is: 1. Open Standard(RFC 7519). 2. Securely transfer information between any two bodies i.e any two users, any two servers. 3. Digitally signed - information is verified and trusted.

<?php
$data =  array(www.mtalkz.com)

‘dest’ => ‘0000000000’,

‘msg’=>’This is Test message’,

‘pass’=>’xyz’,

‘send’=>’ALERTS’,

‘uname’=>’ xyz ‘,

‘wapurl’=>’www.mtalkz.com‘

);

$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://mtalkz.com/developer-tools/",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 30,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => $data,

CURLOPT_HTTPHEADER => array(

"cache-control: no-cache",

"content-type: multipart/form-data",

),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

}

For only $35, minhaj_dev will integrate , rest, json API. | I have implemented payment and many other API's.I can create API for your website and also integrate 3rd party API. This Gig Include Integration or | On Fiverr

<?php
$data =  array(www.mtalkz.com)

‘dest’ => ‘0000000000’,

‘msg’=>’This is Test message’,

‘pass’=>’xyz’,

‘send’=>’ALERTS’,

‘uname’=>’ xyz ‘,

‘wapurl’=>’www.mtalkz.com‘

);

$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://mtalkz.com/developer-tools/",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 30,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => $data,

CURLOPT_HTTPHEADER => array(

"cache-control: no-cache",

"content-type: multipart/form-data",

),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

}

How to Integrate JSON API from website. 1. Adding a JSON plugin in a Magento-Wordpress integration. 2. Good practice to return DateTime from PHP to JS. 0.

Figure: Reading JSON from URL with JQuery. In the figure we can see the current date, time, and Unix time. Reading JSON with Fetch API. Fetch API is interface for fetching resources. It is similar to XMLHttpRequest but its API provides a more powerful and flexible feature set.

@jduhamel ,. In query editor, click list-> convert to table-> Transform, then change format to text. Community Support Team _ Jimmy Tao. If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Endpoint The exact web address (URI) that points to the requested API functionality. JSON JSON stands for Javascript Object Notation. It is a data format commonly used for APIs requests. OAuth OAuth stands for Open standard authorization. OAuth is an alternative method of authentication that grants access without directly sharing credentials

Comments
  • is it a programming question? If yes, please try to provide info on what is this API you mentioned in form of a function signature. Then translate it into api.jquery.com/jQuery.get call.
  • Last time I did it, someone asked me to include just the link :(