Hello! I am trying to get the content of a ebay web page to scrape the ktypes from a listing. I am using curl and a bearer token, however I got this error when I debugged the data:
Here is my code:
function getWebPage($url, $headers = true){
$ch = curl_init($url);
$authString = "lum-customer-emotiveonline-zone-static:7frngp4swf3r";
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
// CURLOPT_BINARYTRANSFER => true,
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36 ", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 30, // timeout on connect
CURLOPT_TIMEOUT => 30, // timeout on response
CURLOPT_MAXREDIRS => 30, // stop after 10 redirects
CURLOPT_FAILONERROR => false,
// CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
// CURLOPT_COOKIE => "cssg=04b414111690aad33d604bc3f7ea46e5; cid=geijbEE9xVJ7N0ZG%23605806896; AMCVS_A71B5B5B54F607AB0A4C98A2%40AdobeOrg=1; aam_uuid=07802149143316569790303965627458565736; AMCV_A71B5B5B54F607AB0A4C98A2%40AdobeOrg=-1758798782%7CMCIDTS%7C18003%7CMCMID%7C07834148950972156620304900923546603477%7CMCAAMLH-1556031442%7C6%7CMCAAMB-1556105367%7CRKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y%7CMCOPTOUT-1555507767s%7CNONE%7CMCAID%7CNONE%7CMCCIDH%7C1743609267; ak_bmsc=E21B6133C31F3BDE48AD95901E256B6E02142D60F02C00004118B75CC989A639~plbg3SBkDdlJaXW+oV0rFEbi4xwsVSE0xtVy1KN1gYkDp0V88HuSms0dzDi4gfKKjmR2fNZdWEqEhZgBsgbUxTjHEKEVjw14mCCY7izNiO/GSaJoqPbd4Uv+OC12ds0QsuZLQNWlkiJyx4E7ujwbTYnsTp45v08o5bqS/Aj+j8kiLxpdTRF/Ymg+5xX9MSCc0WRSlFVkpdOSB65FZJUZjtoOS778xG9h+yP6mKWqNYGuI; npii=btguid/04b414111690aad33d604bc3f7ea46e55e986756^cguid/04b3bf131690ac7146d112d4e6f2edd95e986756^; ns1=BAQAAAWoZJLj4AAaAANgATF6YZ1djNzJ8NjAxXjE1NTMwODczNzEyNjReXjFeM3wyfDV8NHw3fDExXjFeMl40XjNeMTJeMTJeMl4xXjFeMF4xXjBeMV42NDQyNDU5MDc1JTRWDUgXMPiaocOVWvdZEzSsCY0*; s=CgAD4ACBcuIVXMDRiNDE0MTExNjkwYWFkMzNkNjA0YmMzZjdlYTQ2ZTUA7gAYXLiFVzAGaHR0cHM6Ly93d3cuZWJheS5jb20vB+N/s2U*; ebay=%5Edv%3D5cb6fbb0%5Esbf%3D%23400000000010000000000%5Ecv%3D15555%5Ejs%3D1%5E; dp1=bu1p/QEBfX0BAX19AQA**5e986757^bl/BG60799ad7^pbf/%23c000e000108100420000005e986757^; nonsession=BAQAAAWoZJLj4AAaAAAgAHFzewNcxNTU1NTEwMjI5eDM1MjM1NTY0MjYxNXgweDJOADMACV6YZ1cxMDAxMCxVU0EAygAgZh01VzA0YjQxNDExMTY5MGFhZDMzZDYwNGJjM2Y3ZWE0NmU1AMsAAly3Ot8yMOTYxKBxgVsylJqRQ24A1tCA+BMM"
// CURLOPT_PROXY => '108.59.14.203:13010'
);
curl_setopt_array( $ch, $options );
if ($headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer v^1.1#i^1#r^1#p^1#f^0#I^3#t^Ul43XzEwOjYzQUMzQjFCNDlBRjBGQzZDOUY0ODFDQzY0QjRCRkI3XzBfMSNFXjI2MA==",
"Origin: https://www.ebay.com",
"X-EBAY-C-MARKETPLACE-ID: EBAY-US",
"X-EBAY-C-CORRELATION-SESSION: cgi=f1e50d1316c0ac7302f4cf5aff81ef0f"
));
}else
{
}
//curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:24000');
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $authString);
$img = curl_exec($ch);
$errno = curl_errno( $ch );
$errmsg = curl_error( $ch );
if ($errno != 0 ) {
echo $errno." - ".$errmsg ."\r\n";
}
if(strpos($errmsg, "403 Forbidden" !== false)){
die();
}
$n = 0;
return $img;
}
$headers = array(
"Content-Type" => "application/json",
"Authorization" => "Bearer v^1.1#i^1#r^1#p^1#f^0#I^3#t^Ul43XzEwOjYzQUMzQjFCNDlBRjBGQzZDOUY0ODFDQzY0QjRCRkI3XzBfMSNFXjI2MA==",
"Origin" => "https://www.ebay.com",
"X-EBAY-C-MARKETPLACE-ID" => "EBAY-US",
"X-EBAY-C-CORRELATION-SESSION" => "cgi=f1e50d1316c0ac7302f4cf5aff81ef0f"
);
$authString = "lum-customer-emotiveonline-zone-static:7frngp4swf3r";
$ktypes = array();
// $id = "282909215403";
$response = getWebPage('https://api.ebay.com/parts_compatibility/v1/compatible_products/listing/153334269663?fieldgroups=full&limit=100', ['headers' => $headers]);
$json = json_decode($response);
print_r($json);die();