SDKs
PHP
Thunderbit Open API를 위한 PHP의 관용적인 패턴
Guzzle 을 사용하세요. Composer 한 줄로 설치되며, PHP 8.1+ 에서 동작합니다.
설치
composer require guzzlehttp/guzzle설정
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$api = new Client([
'base_uri' => 'https://openapi.thunderbit.com/openapi/v1/',
'headers' => [
'Authorization' => 'Bearer ' . getenv('THUNDERBIT_API_KEY'),
'Content-Type' => 'application/json',
],
'timeout' => 60,
]);페이지 Distill
$res = $api->post('distill', [
'json' => ['url' => 'https://thunderbit.com/playground'],
]);
$data = json_decode($res->getBody(), true);
echo $data['data']['markdown'];구조화된 데이터 Extract
$res = $api->post('extract', [
'json' => [
'url' => 'https://example.com/product/iphone-15-pro',
'schema' => [
'type' => 'object',
'properties' => [
'name' => ['type' => 'string'],
'price' => ['type' => 'number'],
],
'required' => ['name', 'price'],
],
],
]);
$data = json_decode($res->getBody(), true)['data'];Batch + Webhook
$job = json_decode($api->post('batch/distill', [
'json' => [
'urls' => ['https://example.com/page1', 'https://example.com/page2'],
'webhook' => [
'url' => 'https://your-server.com/webhook',
'secret' => getenv('WEBHOOK_SECRET'),
],
],
])->getBody(), true);
error_log('Batch submitted: ' . $job['data']['id']);핸들러에서 Webhook 시그니처를 검증하세요 —— Webhooks 를 참고하세요.
공식 PHP SDK 가 개발 중입니다 —— 곧 다시 확인해 주세요.