โดย birdkritsna » 21/09/2019 3:02 pm
mindphp เขียน:เป็นอย่างไรบ้าง กับคำแนะนำ ที่ให้ไป
ลองทำตามในกระทู้แล้วครับ ขึ้น error ครับ
โค้ด: เลือกทั้งหมด
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/"
. "?start_period=2019-09-19&"
. "end_period=2019-09-20&"
. "currency=USD",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"x-ibm-client-id: 41a7650e-697b-4c11-968b-b982bac08687"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$result = json_decode($matchs[1], true);
$player_response = json_decode($result['args']['player_response'], true);
$exchange = $player_response['data_detail']['exchange'];
echo print_r($exchange);
curl_close($curl);
หน้าจอ
- q4.jpg (21.73 KiB) Viewed 165 times
รบกวนแนะนำเพิ่มเติมหน่อยครับ ว่าผิดถูกตรงไหนครับผม
[quote="mindphp"]เป็นอย่างไรบ้าง กับคำแนะนำ ที่ให้ไป[/quote]
ลองทำตามในกระทู้แล้วครับ ขึ้น error ครับ
[code]<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/"
. "?start_period=2019-09-19&"
. "end_period=2019-09-20&"
. "currency=USD",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"x-ibm-client-id: 41a7650e-697b-4c11-968b-b982bac08687"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$result = json_decode($matchs[1], true);
$player_response = json_decode($result['args']['player_response'], true);
$exchange = $player_response['data_detail']['exchange'];
echo print_r($exchange);
curl_close($curl);[/code]
หน้าจอ
[attachment=0]q4.jpg[/attachment]
รบกวนแนะนำเพิ่มเติมหน่อยครับ ว่าผิดถูกตรงไหนครับผม