<?php
$data = '{"request": {"header": {"username": "xxxxxxx","password": "xxxx"},
"body": {
"shapes": [],
"size_to": "",
"size_from": "",
"color_from": "",
"color_to": "",
"clarity_from": "",
"clarity_to": "",
"cut_from": "",
"cut_to": "",
"polish_from": "",
"polish_to": "",
"symmetry_from": "",
"symmetry_to": "",
"labs": [],
"price_total_from": "",
"price_total_to": "",
"page_number": "1",
"page_size": "20",
"sort_by": "price",
"sort_direction": "ASC"
}}}';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, 'http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
$data = json_decode($result,true);
$diamonds_returned = $data['response']['body']['search_results']['diamonds_returned'];
$total_diamonds_found = $data['response']['body']['search_results']['total_diamonds_found'];
echo "<pre>";
print_r($data);
curl_close($curl);
?>
$data = '{"request": {"header": {"username": "xxxxxxx","password": "xxxx"},
"body": {
"shapes": [],
"size_to": "",
"size_from": "",
"color_from": "",
"color_to": "",
"clarity_from": "",
"clarity_to": "",
"cut_from": "",
"cut_to": "",
"polish_from": "",
"polish_to": "",
"symmetry_from": "",
"symmetry_to": "",
"labs": [],
"price_total_from": "",
"price_total_to": "",
"page_number": "1",
"page_size": "20",
"sort_by": "price",
"sort_direction": "ASC"
}}}';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_URL, 'http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
$data = json_decode($result,true);
$diamonds_returned = $data['response']['body']['search_results']['diamonds_returned'];
$total_diamonds_found = $data['response']['body']['search_results']['total_diamonds_found'];
echo "<pre>";
print_r($data);
curl_close($curl);
?>
Thanks man, you're a life saver.
ReplyDeletegives this error
ReplyDeleteArray
(
[response] => Array
(
[header] => Array
(
[error_code] => 2001
[error_message] => You are not authenticated for RapNet InventoryLink web service.
)
[body] => Array
(
)
)
)
I think due to Invalid credentials. please check it.
Delete