Search the Community
Showing results for tags 'shopeeapi'.
Found 2 results
-
Mình muốn lấy dữ liệu liked từ API, đây là cách mình làm, nhưng luôn trả về false( đã login và like sản phẩm). Mong cao nhân chỉ giáo $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, 'https://shopee.vn'); curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlObj, CURLOPT_HEADER, 1); curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curlObj); preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result, $match_found); $cookies = array(); foreach($match_found[1] as $item) { parse_str($item, $cookie); $cookies = array_merge($cookies, $cookie); } curl_close($curlObj); $url = 'https://shopee.vn/api/v2/item/get?shopid=302870756&itemid=5558354179'; $data_shopee = file_get_contents_ex($url, $cookies); $like_check = $data_shopee ['item']['liked']; echo $like_check // ccc function file_get_contents_ex($url, $cookie = null) { $opts = array( 'http' => array( 'method' => 'GET', 'user-agent'=> 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36', 'header' => (!empty($cookie) ? "Cookie: ".http_build_query($cookie, '', '; ')."\r\n" : ''), ) ); $context = stream_context_create($opts); $contents = file_get_contents($url, false, $context); $json_data = json_decode($contents, true); return $json_data; }
-
Mình sử dụng api :https://shopee.vn/api/v2/search_items/?by=pop&limit=30&match_id=166011623&newest=30&order=desc&page_type=shop&version=2 get được chuỗi json các sản phẩm của 1 shop nhưng phần ảnh thì bị lỗi, ở phần trình duyệt nó có thêm một chuỗi phía sau nữa . Mọi người ai có kinh nghiệm get ảnh này rồi mình mong có thể chia sẻ với ạ