[PHP] การส่งข้อมูล raw JSON body ด้วย Guzzle

 การส่งข้อมูล raw JSON body (แบบที่ใช้ใน Postman) ด้วย Guzzle


$url = 'https://www.example.com';
$client = new \GuzzleHttp\Client();
$data = [//ข้อมูลที่ต้องการส่ง
    'foo' => 'bar',
    'name' => 'test',
];
$response = $client->request("POST", $url, [
    'json' => $data,
    'headers' => [
        'Content-Type' => 'application/json; charset=utf-8',
        'Accept' => 'application/json',
    ],
]);

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

[Blue Archive] รวมล็อบบี้ความทรงจำ (Live2D)

[Blue Archive] รีวิวมารินะ (Marina)

[Blue Archive] รีวิวชินัตสึ (Chinatsu)

[Blue Archive] รีวิวโฮชิโนะ (Hoshino)

[Blue Archive] รีวิวจุนโกะ (Junko)