Buna ziua!
Incerc sa obtin baza de date de la GSMArena in baza mea de date MySql (cu acest API) si sa o mentin actualizata
Nu sunt programator asa ca intampin diferite probleme.
Rezultatul la cererea prin API arata in felul acesta:
{
"status": 200,
"message": "Success",
"data": {
"key": "apple_iphone_13_pro_max-11089",
"device_name": "Apple iPhone 13 Pro Max",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-13-pro-max.jpg",
"display_size": "6.7\"",
"display_res": "1284x2778 pixels",
"camera": "12MP",
"video": "2160p",
"ram": "6GB RAM",
"chipset": "Apple A15 Bionic",
"battery": "4352mAh",
"batteryType": "Li-Ion",
"release_date": "Released 2021, September 24",
"body": "240g, 7.7mm thickness",
"os_type": "iOS 15, up to iOS 15.5",
"storage": "128GB/256GB/1TB storage, no card slot",
"comment": "Versions: A2643 (International); A2484 (USA); A2641 (Canada, Japan); A2644 (China, Hong Kong); A2645 (Russia)",
"more_specification": [
{
"title": "Network",
"data": [
{
"title": "Technology",
"data": [
"GSM / CDMA / HSPA / EVDO / LTE / 5G"
]
},
{
"title": "2G bands",
"data": [
"GSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2 (dual-SIM)"
]
},
{
"title": "3G bands",
"data": [
"HSDPA 850 / 900 / 1700(AWS) / 1900 / 2100"
]
},
{
"title": "4G bands",
"data": [
"1, 2, 3, 4, 5, 7, 8, 12, 13, 17, 18, 19, 20, 25, 26, 28, 30, 32, 34, 38, 39, 40, 41, 42, 46, 48, 66 - A2643, A2644, A2645"
]
},
{
"title": "5G bands",
"data": [
"1, 2, 3, 5, 7, 8, 12, 20, 25, 28, 30, 38, 40, 41, 48, 66, 77, 78, 79 SA/NSA/Sub6 - A2643, A2644"
]
},
{
"title": "Speed",
"data": [
"HSPA 42.2/5.76 Mbps, LTE-A, 5G, EV-DO Rev.A 3.1 Mbps"
]
}
]
},
{
"title": "Launch",
"data": [
{
"title": "Announced",
"data": [
"2021, September 14"
]
},
{
"title": "Status",
"data": [
"Available. Released 2021, September 24"
]
}
]
},
{
"title": "Body",
"data": [
{
"title": "Dimensions",
"data": [
"160.8 x 78.1 x 7.7 mm (6.33 x 3.07 x 0.30 in)"
]
},
{
"title": "Weight",
"data": [
"240 g (8.47 oz)"
]
},
{
"title": "Build",
"data": [
"Glass front (Gorilla Glass), glass back (Gorilla Glass), stainless steel frame"
]
},
{
"title": "SIM",
"data": [
"Single SIM (Nano-SIM and/or eSIM) or Dual SIM (Nano-SIM/eSIM, dual stand-by)"
]
}
]
},
{
"title": "Display",
"data": [
{
"title": "Type",
"data": [
"Super Retina XDR OLED, 120Hz, HDR10, Dolby Vision, 1000 nits (HBM), 1200 nits (peak)"
]
},
{
"title": "Size",
"data": [
"6.7 inches, 109.8 cm2 (~87.4% screen-to-body ratio)"
]
},
{
"title": "Resolution",
"data": [
"1284 x 2778 pixels, 19.5:9 ratio (~458 ppi density)"
]
},
{
"title": "Protection",
"data": [
"Scratch-resistant ceramic glass, oleophobic coating"
]
}
]
},
{
"title": "Platform",
"data": [
{
"title": "OS",
"data": [
"iOS 15, up to iOS 15.5, planned upgrade to iOS 16"
]
},
{
"title": "Chipset",
"data": [
"Apple A15 Bionic (5 nm)"
]
},
{
"title": "CPU",
"data": [
"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)"
]
},
{
"title": "GPU",
"data": [
"Apple GPU (5-core graphics)"
]
}
]
},
{
"title": "Memory",
"data": [
{
"title": "Card slot",
"data": [
"No"
]
},
{
"title": "Internal",
"data": [
"128GB 6GB RAM, 256GB 6GB RAM, 512GB 6GB RAM, 1TB 6GB RAM"
]
}
]
},
{
"title": "Main Camera",
"data": [
{
"title": "Quad",
"data": [
"12 MP, f/1.5, 26mm (wide), 1.9µm, dual pixel PDAF, sensor-shift OIS\n12 MP, f/2.8, 77mm (telephoto), PDAF, OIS, 3x optical zoom\n12 MP, f/1.8, 13mm, 120˚ (ultrawide), PDAF\nTOF 3D LiDAR scanner (depth)"
]
},
{
"title": "Features",
"data": [
"Dual-LED dual-tone flash, HDR (photo/panorama)"
]
},
{
"title": "Video",
"data": [
"4K@24/30/60fps, 1080p@30/60/120/240fps, 10-bit HDR, Dolby Vision HDR (up to 60fps), ProRes, Cinematic mode, stereo sound rec."
]
}
]
},
{
"title": "Selfie camera",
"data": [
{
"title": "Dual",
"data": [
"12 MP, f/2.2, 23mm (wide), 1/3.6\"\nSL 3D, (depth/biometrics sensor)"
]
},
{
"title": "Features",
"data": [
"HDR"
]
},
{
"title": "Video",
"data": [
"4K@24/25/30/60fps, 1080p@30/60/120fps, gyro-EIS"
]
}
]
},
{
"title": "Sound",
"data": [
{
"title": "Loudspeaker",
"data": [
"Yes, with stereo speakers"
]
},
{
"title": "3.5mm jack",
"data": [
"No"
]
}
]
},
{
"title": "Comms",
"data": [
{
"title": "WLAN",
"data": [
"Wi-Fi 802.11 a/b/g/n/ac/6, dual-band, hotspot"
]
},
{
"title": "Bluetooth",
"data": [
"5.0, A2DP, LE"
]
},
{
"title": "GPS",
"data": [
"Yes, with A-GPS, GLONASS, GALILEO, BDS, QZSS"
]
},
{
"title": "NFC",
"data": [
"Yes"
]
},
{
"title": "Radio",
"data": [
"No"
]
},
{
"title": "USB",
"data": [
"Lightning, USB 2.0"
]
}
]
},
{
"title": "Features",
"data": [
{
"title": "Sensors",
"data": [
"Face ID, accelerometer, gyro, proximity, compass, barometer"
]
}
]
},
{
"title": "Battery",
"data": [
{
"title": "Type",
"data": [
"Li-Ion 4352 mAh, non-removable (16.75 Wh)"
]
},
{
"title": "Charging",
"data": [
"Fast charging (27W, unofficial rating), 50% in 30 min (advertised)\nUSB Power Delivery 2.0\nMagSafe wireless charging 15W\nQi magnetic fast wireless charging 7.5W"
]
}
]
},
{
"title": "Misc",
"data": [
{
"title": "Colors",
"data": [
"Graphite, Gold, Silver, Sierra Blue, Alpine Green"
]
},
{
"title": "Models",
"data": [
"A2643, A2484, A2641, A2644, A2645, iphone14,3"
]
},
{
"title": "SAR",
"data": [
"1.18 W/kg (head) 1.20 W/kg (body)"
]
},
{
"title": "SAR EU",
"data": [
"0.99 W/kg (head) 0.98 W/kg (body)"
]
},
{
"title": "Price",
"data": [
"$ 1,027.99 / £ 999.00 / € 1,202.00 / ₹ 126,900 / Rp 23,681,736"
]
}
]
},
{
"title": "Tests",
"data": [
{
"title": "Performance",
"data": [
"AnTuTu: 801691 (v9)\nGeekBench: 4706 (v5.1)\nGFXBench: 60fps (ES 3.1 onscreen)"
]
},
{
"title": "Display",
"data": [
"Contrast ratio: Infinite (nominal)"
]
},
{
"title": "Camera",
"data": [
"Photo / Video"
]
},
{
"title": "Loudspeaker",
"data": [
"-24.0 LUFS (Very good)"
]
},
{
"title": "Battery life",
"data": [
"Endurance rating 121h"
]
}
]
}
],
"prices": {
"128GB 6GB RAM": [
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/ebay-com2.png",
"price": "$ 1,027.99",
"buy_url": "https://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=2&toolid=10044&campid=5338659500&customid=gsmarena&lgeo=1&vectorid=229466&item=284664052319"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/amazon-com1.png",
"price": "$ 1,099.00",
"buy_url": "https://www.amazon.com/dp/B09G9LN82D?tag=gsmarena093-20&linkCode=osi&th=1&psc=1"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/best-buy-1.png",
"price": "$ 1,099.99",
"buy_url": "https://bestbuy.7tiv.net/c/376373/633495/10014?prodsku=6443227&u=http%3A%2F%2Fwww.bestbuy.com%2Fsite%2F-%2F6443227.p%3Fcmp%3DRMX"
}
],
"256GB 6GB RAM": [
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/ebay-com2.png",
"price": "$ 1,148.99",
"buy_url": "https://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=2&toolid=10044&campid=5338659500&customid=gsmarena&lgeo=1&vectorid=229466&item=284606495982"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/amazon-com1.png",
"price": "$ 1,199.00",
"buy_url": "https://www.amazon.com/dp/B09G8Y5SM6?tag=gsmarena093-20&linkCode=osi&th=1&psc=1"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/best-buy-1.png",
"price": "$ 1,199.99",
"buy_url": "https://bestbuy.7tiv.net/c/376373/633495/10014?prodsku=6443233&u=http%3A%2F%2Fwww.bestbuy.com%2Fsite%2F-%2F6443233.p%3Fcmp%3DRMX"
}
],
"512GB 6GB RAM": [
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/amazon-com1.png",
"price": "$ 1,399.00",
"buy_url": "https://www.amazon.com/dp/B09G9J47CQ?tag=gsmarena093-20&linkCode=osi&th=1&psc=1"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/ebay-com2.png",
"price": "$ 1,399.00",
"buy_url": "https://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=2&toolid=10044&campid=5338659500&customid=gsmarena&lgeo=1&vectorid=229466&item=284752225215"
},
{
"shop_image": "https://fdn.gsmarena.com/imgroot/static/stores/best-buy-1.png",
"price": "$ 1,399.99",
"buy_url": "https://bestbuy.7tiv.net/c/376373/633495/10014?prodsku=6443343&u=http%3A%2F%2Fwww.bestbuy.com%2Fsite%2F-%2F6443343.p%3Fcmp%3DRMX"
}
]
},
"pictures": [
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-01.jpg",
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-1.jpg",
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-5.jpg",
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-2.jpg",
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-3.jpg",
"https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-13-pro-max-4.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_002.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_003.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_004.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_005.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_006.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_007.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_008.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_009.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_010.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_011.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_012.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_013.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_014.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_015.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_016.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_017.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_018.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_019.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_020.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_021.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_022.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_023.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_024.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_025.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_026.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_027.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_028.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_029.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_030.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_031.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_032.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_033.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_034.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_035.jpg",
"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1024w2/gsmarena_036.jpg"
],
"more_information": {
"Related Devices": [
{
"device_name": "Samsung Galaxy S22 Ultra 5G",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-s22-ultra-5g.jpg",
"key": "samsung_galaxy_s22_ultra_5g-11251"
},
{
"device_name": "Apple iPhone 13 Pro",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-13-pro.jpg",
"key": "apple_iphone_13_pro-11102"
},
{
"device_name": "Apple iPhone 12 Pro Max",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-12-pro-max-.jpg",
"key": "apple_iphone_12_pro_max-10237"
},
{
"device_name": "Apple iPhone 13",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-13.jpg",
"key": "apple_iphone_13-11103"
},
{
"device_name": "Apple iPhone 11 Pro Max",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-11-pro.jpg",
"key": "apple_iphone_11_pro_max-9846"
},
{
"device_name": "Xiaomi 12S Ultra",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/xiaomi-12s-ultra.jpg",
"key": "xiaomi_12s_ultra-11614"
}
],
"Popular from Apple": [
{
"device_name": "Apple iPhone 13 Pro Max",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-13-pro-max.jpg",
"key": "apple_iphone_13_pro_max-11089"
},
{
"device_name": "Apple iPhone XR",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-xr-new.jpg",
"key": "apple_iphone_xr-9320"
},
{
"device_name": "Apple iPhone X",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-x.jpg",
"key": "apple_iphone_x-8858"
},
{
"device_name": "Apple iPhone XS Max",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-xs-max-new1.jpg",
"key": "apple_iphone_xs_max-9319"
},
{
"device_name": "Apple iPhone 13",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-13.jpg",
"key": "apple_iphone_13-11103"
},
{
"device_name": "Apple iPhone 11",
"device_image": "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-11.jpg",
"key": "apple_iphone_11-9848"
}
]
}
}
}
Am reusit sa inserez in baza de date key, device_name, device_image, …, comment
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$body = '{
"route": "device-detail",
"key": "'.$mobile->key.'"
}';
$request = new Request('POST', 'https://script.google.com/macros/s/AKfycbxNu27V2Y2LuKUIQMK8lX1y0joB6YmG6hUwB1fNeVbgzEh22TcDGrOak03Fk3uBHmz-/exec', $headers, $body);
$res = $client->sendAsync($request)->wait();
$gsm_device = $res->getBody();
$g_device = json_decode($gsm_device);
$device = $g_device->data;
$db->query(sprintf("INSERT INTO device (brand_name, brand_key, ..., more_specification) VALUES (%s, %s, ..., %s)", secure($model->brand_name), secure($model->key), ..., secure($device->device_image), secure($device->key), secure($device->more_specification) )) or _error("SQL_ERROR_THROWEN");
De la data->more_specification lucrurile pentru mine s-au complicat.
Nu stiu cum sa introduc mai departe rezultatele din more_specification. Nu mai sunt valori unice, title si data se tot repeta si nu stiu cum sa fac.
Exista o posibilitate sa introduc tot ce este in more_specification intr-o coloana din baza de date ca continut html, ca un tabel?