Developer Forum [ All Topics | New Topic ]

Thread: Rapaport feed php

Hi,

I am using this php sample
to retreive the diamond data via the instant inventory. (I wanted to build a custom template instead of using the pre-defined templates).

It's kinda working but not as expected. They "main" data is returned as a string in one "any"-array. It's looking like this

current resultstdClass Object (
[GetDiamondsResult] => stdClass Object (
[schema] =>
[any] => 71711427Round0.300II1GoodGIA198.0000447.00006212858099BM-91616GoodVery Good65.458.004.124.142.70ThickVery ThickFacetedNoneMedium10.89015451EUR€397 (...and so on)
)
[DiamondsFound] => 9907
)


Is there a way to split it into multi dimensional arrays like in the price sheet? So I get something like this?

wished responsestdClass Object (
[GetDiamondsResult] => stdClass Object (
[schema] =>
[any] =>
[type] => 71711427
[form] => Round
[size] => 0.300
... and so on
)
[DiamondsFound] => 9907
)


>> add a comment
Phil
09/13/2016 11:47


3 Replies:

Hey,
the response is XML format, not plain text. i'll check it, but anyway, we found that our JSON API is much easier to PHP programmers. you can give it a try https://technet.rapaport.com:449/Info/RapLink/Format_Json.aspx

Ephraim
 


>> add a comment
Ephraim
9/13/2016 12:28:00 PM
try the code below :
$client = new SoapClient("https://technet.rapaport.com/WebServices/RetailFeed/Feed.asmx?WSDL",
array( "trace" => 1, "exceptions" => 0, "cache_wsdl" => 0) );
$params = array("Username"=>"USERNAME", "Password"=>"PASSWORD");
$client->__soapCall("Login", array($params), NULL, NULL, $output_headers);
$ticket = $output_headers["AuthenticationTicketHeader"]->Ticket;
$client1 = new SoapClient("https://technet.rapaport.com/WebServices/RetailFeed/Feed.asmx?WSDL", array( "trace" => 1, "exceptions" => 0, "cache_wsdl" => 0) );
$ns = "http://technet.rapaport.com/";
$headerBody = array("Ticket" => $ticket);
$header = new SoapHeader($ns, "AuthenticationTicketHeader", $headerBody);
$client1->__setSoapHeaders($header);
$searchParams = array(
"ShapeCollection" => array("ROUND", "PEAR", "PRINCESS", "MARQUISE", "OVAL", "RADIANT", "EMERALD", "HEART", "CUSHION","ASSCHER"),
"LabCollection" => array("GIA","IGI","HRD"),
"PageNumber" => 1,
"PageSize" => 10,
"FluorescenceIntensities" => "Medium",
"SortDirection" => "ASC",
"SortBy" => "PRICE"
);
$params1 = array("SearchParams" => $searchParams, "DiamondsFound" => 0);
$client1->__soapCall("GetDiamonds", array($params1), NULL, NULL, $output_headers);
$xmlObj = new DOMDocument();
$xmlObj->loadXML($client1->__getLastResponse());
foreach($xmlObj->getElementsByTagName("DiamondsFound") as $diamondFound){
echo ("Diamonds Found:".$diamondFound->nodeValue);
echo "<br />";
echo "<br />"; }
echo "<br />";
foreach($xmlObj->getElementsByTagName("Table1") as $table){
foreach($table->childNodes as $vals){
print ( $vals->nodeName." : ".$vals->nodeValue."<br/>");
}
echo "<br />";
echo "<br />";
}


>> add a comment
Reuven
9/14/2016 1:56:00 AM
I tried the above code but i got the error message -"DOMDocument::loadXML(): Empty string supplied as input....on line 24" . Can you please help me with that?

>> add a comment
Malav
4/13/2017 11:42:00 AM