Forum Moderators: coopster
<?php
$endpoint = 'https://api.upcitemdb.com/prod/trial/lookup';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
// HTTP GET
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, $endpoint.'?upc=4002293401102');
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode != 200)
echo "error status $httpcode...\n";
else
echo $response;
/* if you need to run more queries, do them in the same connection.
* use rawurlencode() instead of URLEncode(), if you set search string
* as url query param
*/
sleep(2);
// proceed with other queries
curl_close($ch);
?>
HTTP/1.1 200 OK
Server: openresty/1.9.7.4
Date: Tue, 06 Jun 2017 14:57:34 GMT
Content-Type: application/json;
charset=utf-8
Content-Length: 2986
Connection: keep-alive
X-Powered-By: Express
X-RateLimit-Limit: 100
X-RateLimit-Reset: 1496782300
X-RateLimit-Remaining: 58
ETag: W/"baa-BVo3BGeKmp0AnMo8J1wJzg"
Vary: Accept-Encoding
Access-Control-Allow-Origin: http://www.upcitemdb.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type,Accept
Access-Control-Expose-Headers: Content-Type,X-RateLimit-Remaining,X-RateLimit-Limit,X-RateLimit-Reset,total,offset
{
"code":"OK",
"total":1,
"offset":0,
"items":[
{
"ean":"4002293401102",
"title":"Wusthof Gourmet 3-Inch Serrated Paring Knife",
"description":"A Wusthof Gourmet stamped knife is great for newer cooks or for use in a second home. These value priced knives are quite sharp. Thanks to their high-carbon stainless steel, their sharp edge is long lasting. Triple riveted handles are extremely durable. Hand wash only. Lifetime warranty from Wusthof with normal use and proper care. Made in Solingen Germany.",
"brand":"W?sthof",
"model":"4011-7",
"color":"Multi",
"size":"",
"dimension":"8 X 1X 1 inches",
"weight":"0.1 Pounds",
"currency":"",
"lowest_recorded_price":12.99,
"images":[
"http://www.chefscatalog.com/img/products/500x500/99528_500.jpg",
"http://img1.r10.io/PIC/84707643/0/1/250/84707643.jpg",
"http://c.shld.net/rpx/i/s/pi/mp/33108/2456981411?src=http%3A%2F%2Fwww.chefscatalog.com%2Fimg%2Fproducts%2F1000x1000%2F99528_1000.jpg&d=8ba15ee3bfc8785ae78e62c3c0762bcb86214ed4",
"http://images10.newegg.com/ProductImageCompressAll200/A0NV_1_20120523_5340513.jpg",
"http://images.prosperentcdn.com/images/250x250/cdn.metrokitchen.com/images/uploads/wu-4011-zoomed.jpg"
],
"offers":[
{
"merchant":"MetroKitchen",
"domain":"metrokitchen.com",
"title":"Wusthof Gourmet 3 inch Serrated Paring Knife",
"currency":"",
"list_price":"",
"price":19.95,
"shipping":"",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=y2x203y2x26384&tid=1&seq=1496761054&plt=b5697879cd221535aad6e95eaaf9f6db",
"updated_t":1466567204},
{
"merchant":"Newegg.com",
"domain":"newegg.com",
"title":"Wusthof Gourmet - 3\" Serrated Utility Knife",
"currency":"",
"list_price":"",
"price":15.95,
"shipping":"5.95",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=v2t2z2u2v2x2c4a4&tid=1&seq=1496761054&plt=8eddebbd84f61019330190997bc18710",
"updated_t":1481154945
},
{
"merchant":"Sears",
"domain":"sears.com",
"title":"Wusthof Gourmet 3-in. Serrated Paring Knife",
"currency":"",
"list_price":"",
"price":19.95,
"shipping":"",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=u2p2631343x2a4d4x2&tid=1&seq=1496761054&plt=cf765b1568727577c5226c5efe2474a3",
"updated_t":1425619323
},
{
"merchant":"Rakuten(Buy.com)",
"domain":"rakuten.com",
"title":"Wusthof Gourmet - 3 Serrated Utility Knife",
"currency":"",
"list_price":"",
"price":16.95,
"shipping":"5.95",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=w2v233w21303c444&tid=1&seq=1496761054&plt=05b7eba2926539453d156d9b2534e1ca",
"updated_t":1496267872
},
{
"merchant":"Chefs Catalog",
"domain":"chefscatalog.com",
"title":"Wusthof Gourmet 3-in. Serrated Paring Knife - Wusthof Gourmet",
"currency":"",
"list_price":26,"price":15.95,
"shipping":"Free Shipping",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=u2o243z2w203b454s2&tid=1&seq=1496761054&plt=b09daf52d0180981bead3c50a6b56b45",
"updated_t":1448989675
}
],
"asin":"B0000DJYE3",
"elid":"282501593152"
}
]
}
<?php
$content = '
{
"code":"OK",
"total":1,
"offset":0,
"items":[
{
"ean":"4002293401102",
"title":"Wusthof Gourmet 3-Inch Serrated Paring Knife",
"description":"A Wusthof Gourmet stamped knife is great for newer cooks or for use in a second home. These value priced knives are quite sharp. Thanks to their high-carbon stainless steel, their sharp edge is long lasting. Triple riveted handles are extremely durable. Hand wash only. Lifetime warranty from Wusthof with normal use and proper care. Made in Solingen Germany.",
"brand":"W?sthof",
"model":"4011-7",
"color":"Multi",
"size":"",
"dimension":"8 X 1X 1 inches",
"weight":"0.1 Pounds",
"currency":"",
"lowest_recorded_price":12.99,
"images":[
"http://www.chefscatalog.com/img/products/500x500/99528_500.jpg",
"http://img1.r10.io/PIC/84707643/0/1/250/84707643.jpg",
"http://c.shld.net/rpx/i/s/pi/mp/33108/2456981411?src=http%3A%2F%2Fwww.chefscatalog.com%2Fimg%2Fproducts%2F1000x1000%2F99528_1000.jpg&d=8ba15ee3bfc8785ae78e62c3c0762bcb86214ed4",
"http://images10.newegg.com/ProductImageCompressAll200/A0NV_1_20120523_5340513.jpg",
"http://images.prosperentcdn.com/images/250x250/cdn.metrokitchen.com/images/uploads/wu-4011-zoomed.jpg"
],
"offers":[
{
"merchant":"MetroKitchen",
"domain":"metrokitchen.com",
"title":"Wusthof Gourmet 3 inch Serrated Paring Knife",
"currency":"",
"list_price":"",
"price":19.95,
"shipping":"",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=y2x203y2x26384&tid=1&seq=1496761054&plt=b5697879cd221535aad6e95eaaf9f6db",
"updated_t":1466567204},
{
"merchant":"Newegg.com",
"domain":"newegg.com",
"title":"Wusthof Gourmet - 3\" Serrated Utility Knife",
"currency":"",
"list_price":"",
"price":15.95,
"shipping":"5.95",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=v2t2z2u2v2x2c4a4&tid=1&seq=1496761054&plt=8eddebbd84f61019330190997bc18710",
"updated_t":1481154945
},
{
"merchant":"Sears",
"domain":"sears.com",
"title":"Wusthof Gourmet 3-in. Serrated Paring Knife",
"currency":"",
"list_price":"",
"price":19.95,
"shipping":"",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=u2p2631343x2a4d4x2&tid=1&seq=1496761054&plt=cf765b1568727577c5226c5efe2474a3",
"updated_t":1425619323
},
{
"merchant":"Rakuten(Buy.com)",
"domain":"rakuten.com",
"title":"Wusthof Gourmet - 3 Serrated Utility Knife",
"currency":"",
"list_price":"",
"price":16.95,
"shipping":"5.95",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=w2v233w21303c444&tid=1&seq=1496761054&plt=05b7eba2926539453d156d9b2534e1ca",
"updated_t":1496267872
},
{
"merchant":"Chefs Catalog",
"domain":"chefscatalog.com",
"title":"Wusthof Gourmet 3-in. Serrated Paring Knife - Wusthof Gourmet",
"currency":"",
"list_price":26,"price":15.95,
"shipping":"Free Shipping",
"condition":"New",
"availability":"",
"link":"http://www.upcitemdb.com/norob/alink/?id=u2o243z2w203b454s2&tid=1&seq=1496761054&plt=b09daf52d0180981bead3c50a6b56b45",
"updated_t":1448989675
}
],
"asin":"B0000DJYE3",
"elid":"282501593152"
}
]
}' ;
$arr = json_decode ( $content , true ) ;
$items = $arr [ 'items' ] ;
$items_count = count ( $items ) ; $headers = curl_getinfo ( $ch ) ; $content = substr ( $response , $headers [ 'header_size' ] ) ;