I'm using ebay api to fetch items to my site with callname=GetSingleItem
and everything is OK.
Please see the below code segments that I used to fetch details of the item
$res = $api -> get ( "http://open.api.ebay.com/shopping?"
. "callname=GetSingleItem&"
.
"IncludeSelector=Description,ItemSpecifics,Details&"
. "ItemID=" . $listing -> platform_key . '&'
. "appid=$ebayAppId&"
. "version=".$version ) ;
$xml = simplexml_load_string ( $res -> getBody () ) ;
$json = json_encode ( $xml ) ;
$jsonResult = json_decode ( $json , TRUE ) ;
Then I fetch Its details via below code segment
$ebayItemArray[ "description" ] = ( $jsonResult[ "Item" ][ "Description" ]
)
Please note that above code segments are just sample codes
So I use this description via below code segment in Laravel blade.php
<div class=container text-left">
{!!$ebayItemArray[ "description" ]!!}
</div>
So this works well without any errors for some products but for some products when I try to display description it destroy my layout styles like below
WHEN I REMOVE THE DESCRITION VARIALBE FROM THE BLADE FILE THEN THINGS WORK FINE AS THEY SHOULD BE
As per documentation:
If the Description value is used, the full description is returned, with all HTML, XML, or CSS markup used in the listing (if any) by the seller. To only view the actual text of the listing description (no markup tags), the TextDescription value shall be used instead.
So it's probably the additional CSS that destroys your page structure.
You have the options
// Not tested...
$description = $jsonResult[ "Item" ][ "Description" ];
$doc = new DOMDocument();
$doc->loadHTML($description); // Load as HTML
removeElementsByTagName('style', $doc); // Remove the <style> Tag
$description = strip_tags($doc->textContent); // To plain Text
$ebayItemArray[ "description" ] = $description;
IncludeSelector=TextDescription
$res = $api -> get ( "http://open.api.ebay.com/shopping?"
. "callname=GetSingleItem&"
.
"IncludeSelector=TextDescription,ItemSpecifics,Details&"
. "ItemID=" . $listing -> platform_key . '&'
. "appid=$ebayAppId&"
. "version=".$version ) ;
<iframe
title="Description"
srcdoc="{!!$ebayItemArray[ "description" ]!!}"
width="300px" height="300px"
></iframe>
With iFrame, you also need to auto resize the height of the iFrame.