1

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

4

5 回答 5

1

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' }]]
})))
于 2014-08-28T01:28:52.960 回答
0

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.

于 2013-08-24T18:03:52.750 回答
0

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);    
于 2013-09-05T03:32:49.390 回答
0
<?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;

}
于 2019-01-31T08:04:34.067 回答
0
<?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;

}
于 2019-02-13T13:19:35.823 回答