WebPageTest API를 사용하여 여러 웹사이트를 지역별로 테스트하는 로컬 서버를 구축하는 방법을 자세히 설명드리겠습니다. 

PHP를 활용하여 구축하는 방법은 다음과 같습니다:

WebPageTest API 키 생성:
먼저, WebPageTest 웹사이트에 가입하고 API 키를 생성하세요.(유료 요금제 가입)

API 키는 WebPageTest 테스트 에이전트와 상호작용할 때 사용됩니다.

PHP 스크립트 작성:
원하는 웹사이트를 테스트하고 결과를 받아오기 위해 PHP 스크립트를 작성합니다.
WebPageTest API를 호출하여 테스트를 실행하고 결과를 가져오는 코드를 작성해야 합니다.
WebPageTest API 호출:
WebPageTest API를 호출하여 테스트를 실행합니다.
테스트를 실행하려면 runtest.php 엔드포인트에 POST 또는 GET 요청을 보내야 합니다.
요청에는 API 키, 테스트할 URL 및 테스트를 구성하는 선택적 매개변수가 포함됩니다.
테스트가 완료되면 결과를 반환합니다.

응답 형식 설정:
기본적으로 /runtest.php 엔드포인트에 성공적인 요청을 보내면 결과 페이지로 리디렉션됩니다.
응답 형식을 설정하려면 f 매개변수를 사용하여 XML 응답 (f=xml) 또는 JSON 응답 (f=json)을 반환하도록 설정할 수 있습니다.
예제:
다음은 API를 사용하여 테스트를 실행하고 JSON 응답을 받는 예제 URL입니다:
https://www.webpagetest.org/runtest.php?url={your_domain}&k={your_api_key}&f=json

{your_domain}과 {your_api_key}를 실제 도메인과 API 키로 대체하세요.

보안 고려사항:
API 키는 계정에 직접 연결되므로 보안을 유지하세요.
API 키를 공개적인 곳 (예: GitHub 또는 클라이언트 측 코드)에서 공유하지 마세요.

 

WebPageTest API를 사용하여 전체 서버 목록을 확인하려면 다음 단계를 따르세요:

API 문서 확인:
WebPageTest API 문서를 참조하여 지원되는 서버 목록과 사용 가능한 매개변수를 확인하세요.
API 키 생성:
먼저, WebPageTest 웹사이트에 가입하고 API 키를 생성하세요.
API 키는 WebPageTest 테스트 에이전트와 상호작용할 때 사용됩니다.
API 호출:
서버 목록을 가져오기 위해 API를 호출하세요.
다음과 같은 엔드포인트를 사용하여 서버 목록을 확인할 수 있습니다:
https://www.webpagetest.org/getLocations.php?f=json

응답 확인:
위의 URL로 요청을 보내면 JSON 형식으로 지원되는 서버 목록이 반환됩니다.
응답 예시:

{
  "statusCode": 200,
  "statusText": "Ok",
  "data": {
    "ec2-us-east-1": {
      "Label": "Virginia - EC2",
      "location": "ec2-us-east-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Virginia USA - EC2 ",
      "node": "4789",
      "default": true,
      "group": "North America",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 77,
        "Total": 77,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 77,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "gce-us-west3": {
      "Label": "Salt Lake City, Utah - GCE",
      "location": "gce-us-west3",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Salt Lake City, Utah - GCE",
      "node": "4790",
      "group": "North America",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 104,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 3,
        "Total": 107,
        "Queued": 104,
        "HighPriority": 0,
        "LowPriority": 104,
        "Testing": 3,
        "Idle": 0,
        "TestAgentRatio": 35.666666666666664
      }
    },
    "ec2-us-west-1": {
      "Label": "California - EC2",
      "location": "ec2-us-west-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "California, USA - EC2",
      "node": "4791",
      "group": "North America",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 17,
        "Total": 17,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 17,
        "Idle": 1,
        "TestAgentRatio": 0.9444444444444444
      }
    },
    "ec2-ca-central-1": {
      "Label": "Toronto, Canada - EC2",
      "location": "ec2-ca-central-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Toronto, Canada - EC2",
      "node": "4794",
      "group": "North America",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 12,
        "Total": 12,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 12,
        "Idle": 4,
        "TestAgentRatio": 0.75
      }
    },
    "ec2-sa-east-1": {
      "Label": "Sao Paulo, Brazil - EC2",
      "location": "ec2-sa-east-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Sao Paulo, Brazil - EC2",
      "node": "4795",
      "group": "South America",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 7,
        "Total": 7,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 7,
        "Idle": 1,
        "TestAgentRatio": 0.875
      }
    },
    "ec2-eu-west-1": {
      "Label": "Ireland - EC2",
      "location": "ec2-eu-west-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Ireland - EC2",
      "node": "4796",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 3,
        "Total": 3,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 3,
        "Idle": 1,
        "TestAgentRatio": 0.75
      }
    },
    "London_EC2": {
      "Label": "London, UK - EC2",
      "location": "London_EC2",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "London, UK - EC2",
      "node": "4797",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 16,
        "Total": 16,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 16,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-eu-west-3": {
      "Label": "Paris - EC2",
      "location": "ec2-eu-west-3",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Paris - EC2",
      "node": "4798",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 5,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 11,
        "Total": 11,
        "Queued": 6,
        "HighPriority": 1,
        "LowPriority": 5,
        "Testing": 5,
        "Idle": 0,
        "TestAgentRatio": 2.2
      }
    },
    "gce-europe-west4": {
      "Label": "Amsterdam, NL - GCE",
      "location": "gce-europe-west4",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Edge",
      "status": "OK",
      "labelShort": "Amsterdam, NL - GCE",
      "node": "4799",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 4,
        "Total": 4,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 4,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-eu-central-1": {
      "Label": "Frankfurt, Germany - EC2",
      "location": "ec2-eu-central-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Frankfurt, Germany - EC2",
      "node": "4800",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 21,
        "Total": 21,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 21,
        "Idle": 2,
        "TestAgentRatio": 0.9130434782608695
      }
    },
    "ec2-eu-south-1": {
      "Label": "Milan, Italy - EC2",
      "location": "ec2-eu-south-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Milan, Italy - EC2",
      "node": "4801",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 2,
        "Total": 2,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 2,
        "Idle": 1,
        "TestAgentRatio": 0.6666666666666666
      }
    },
    "ec2-eu-north-1": {
      "Label": "Stockholm, Sweden - EC2",
      "location": "ec2-eu-north-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Stockholm, Sweden - EC2",
      "node": "4802",
      "group": "Europe",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 1,
        "Total": 1,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 1,
        "Idle": 1,
        "TestAgentRatio": 0.5
      }
    },
    "ec2-af-south-1": {
      "Label": "Cape Town, South Africa - EC2",
      "location": "ec2-af-south-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Cape Town, South Africa - EC2",
      "node": "4803",
      "group": "Africa",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 3,
        "Total": 3,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 3,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-me-south-1": {
      "Label": "Bahrain - EC2",
      "location": "ec2-me-south-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Bahrain - EC2",
      "node": "4804",
      "group": "Middle East",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 0,
        "Total": 0,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 0,
        "Idle": 1,
        "TestAgentRatio": 0
      }
    },
    "azure-uae-north": {
      "Label": "Dubai, UAE - Azure",
      "location": "azure-uae-north",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OFFLINE",
      "labelShort": "Dubai, UAE - Azure",
      "node": "4805",
      "group": "Middle East",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 0,
        "Total": 0,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 0,
        "Idle": 0,
        "TestAgentRatio": 0
      }
    },
    "ap-south-1": {
      "Label": "Mumbai, India - EC2",
      "location": "ap-south-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Mumbai, India - EC2",
      "node": "4806",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 36,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 4,
        "Total": 40,
        "Queued": 36,
        "HighPriority": 0,
        "LowPriority": 36,
        "Testing": 4,
        "Idle": 0,
        "TestAgentRatio": 10
      }
    },
    "tencent-bangkok": {
      "Label": "Bangkok, Thailand - Tencent",
      "location": "tencent-bangkok",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Bangkok, Thailand - Tencent",
      "node": "4807",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 1,
        "Total": 1,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 1,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-ap-southeast-1": {
      "Label": "Singapore - EC2",
      "location": "ec2-ap-southeast-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Singapore - EC2",
      "node": "4808",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 5,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 354,
        "Total": 359,
        "Queued": 351,
        "HighPriority": 346,
        "LowPriority": 5,
        "Testing": 8,
        "Idle": 1,
        "TestAgentRatio": 39.888888888888886
      }
    },
    "gce-asia-southeast2": {
      "Label": "Jakarta, Indonesia - GCE",
      "location": "gce-asia-southeast2",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Jakarta, Indonesia - GCE",
      "node": "4809",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 5,
        "Total": 5,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 5,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-ap-east-1": {
      "Label": "Hong Kong, China - EC2",
      "location": "ec2-ap-east-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Hong Kong, China - EC2",
      "node": "4810",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 15,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 26,
        "Total": 41,
        "Queued": 37,
        "HighPriority": 22,
        "LowPriority": 15,
        "Testing": 4,
        "Idle": 0,
        "TestAgentRatio": 10.25
      }
    },
    "tencent-shanghai": {
      "Label": "Shanghai, China - Tencent",
      "location": "tencent-shanghai",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Shanghai, China - Tencent",
      "node": "4811",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 0,
        "Total": 0,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 0,
        "Idle": 2,
        "TestAgentRatio": 0
      }
    },
    "tencent-beijing": {
      "Label": "Beijing, China - Tencent",
      "location": "tencent-beijing",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Beijing, China - Tencent",
      "node": "4813",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 1,
        "p3": 0,
        "p4": 0,
        "p5": 21,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 184,
        "Total": 205,
        "Queued": 204,
        "HighPriority": 182,
        "LowPriority": 22,
        "Testing": 1,
        "Idle": 0,
        "TestAgentRatio": 205
      }
    },
    "ec2-cn-northwest-1": {
      "Label": "Ningxia, China - EC2",
      "location": "ec2-cn-northwest-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OFFLINE",
      "labelShort": "Ningxia, China - EC2",
      "node": "4814",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 12,
        "p3": 0,
        "p4": 0,
        "p5": 20,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 12,
        "Total": 32,
        "Queued": 32,
        "HighPriority": 0,
        "LowPriority": 32,
        "Testing": 0,
        "Idle": 0,
        "TestAgentRatio": 32
      }
    },
    "gce-asia-east1": {
      "Label": "Taiwan - GCE",
      "location": "gce-asia-east1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Taiwan - GCE",
      "node": "4815",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 69,
        "Total": 69,
        "Queued": 67,
        "HighPriority": 67,
        "LowPriority": 0,
        "Testing": 2,
        "Idle": 0,
        "TestAgentRatio": 34.5
      }
    },
    "ec2-ap-northeast-2": {
      "Label": "Seoul, Korea - EC2",
      "location": "ec2-ap-northeast-2",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Seoul, Korea - EC2",
      "node": "4816",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 4,
        "Total": 4,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 4,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-ap-northeast-1": {
      "Label": "Tokyo, Japan - EC2",
      "location": "ec2-ap-northeast-1",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Tokyo, Japan - EC2",
      "node": "4817",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 9,
        "Total": 9,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 9,
        "Idle": 3,
        "TestAgentRatio": 0.75
      }
    },
    "ec2-ap-northeast-3": {
      "Label": "Osaka, Japan - EC2",
      "location": "ec2-ap-northeast-3",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Osaka, Japan - EC2",
      "node": "4826",
      "group": "Asia",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 4,
        "Total": 4,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 4,
        "Idle": 0,
        "TestAgentRatio": 1
      }
    },
    "ec2-ap-southeast-2": {
      "Label": "Sydney, Australia - EC2",
      "location": "ec2-ap-southeast-2",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge",
      "status": "OK",
      "labelShort": "Sydney, Australia - EC2",
      "node": "4818",
      "group": "Oceania",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 7,
        "Total": 7,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 7,
        "Idle": 4,
        "TestAgentRatio": 0.6363636363636364
      }
    },
    "azure-australia-southeast": {
      "Label": "Melbourne, Australia - Azure",
      "location": "azure-australia-southeast",
      "Browsers": "Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave",
      "status": "OK",
      "labelShort": "Melbourne, Australia - Azure",
      "node": "4819",
      "group": "Oceania",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 11,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 1,
        "Total": 12,
        "Queued": 11,
        "HighPriority": 0,
        "LowPriority": 11,
        "Testing": 1,
        "Idle": 0,
        "TestAgentRatio": 12
      }
    },
    "LosAngeles_M1MacMini": {
      "Label": "Los Angeles, CA - M1 Mac Mini/iOS (Chrome,Firefox,Safari)",
      "location": "LosAngeles_M1MacMini",
      "Browsers": "Chrome,Chrome Beta,Chrome Dev,Chrome Canary,Safari,Firefox",
      "status": "OK",
      "labelShort": "Los Angeles, CA- M1 Mac Mini",
      "node": "4793",
      "group": "Physical Devices",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 0,
        "Total": 0,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 0,
        "Idle": 2,
        "TestAgentRatio": 0
      }
    },
    "NewYork_M1MacMini": {
      "Label": "New York, NY - M1 Mac Mini/iOS (Chrome,Firefox,Safari)",
      "location": "NewYork_M1MacMini",
      "Browsers": "Chrome,Chrome Beta,Chrome Dev,Chrome Canary,Safari,Firefox",
      "status": "OK",
      "labelShort": "New York, NY- M1 Mac Mini",
      "node": "4785",
      "group": "Physical Devices",
      "PendingTests": {
        "p1": 0,
        "p2": 0,
        "p3": 0,
        "p4": 0,
        "p5": 0,
        "p6": 0,
        "p7": 0,
        "p8": 0,
        "p9": 0,
        "Blocking": 4,
        "Total": 4,
        "Queued": 0,
        "HighPriority": 0,
        "LowPriority": 0,
        "Testing": 4,
        "Idle": 3,
        "TestAgentRatio": 0.5714285714285714
      }
    }
  }
}

 

 

지원 서버 목록, 31개 서버

 

       labelShort        location        Browsers
 Virginia USA - EC2   ec2-us-east-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Salt Lake City, Utah - GCE  gce-us-west3  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 California, USA - EC2  ec2-us-west-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Toronto, Canada - EC2  ec2-ca-central-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Sao Paulo, Brazil - EC2  ec2-sa-east-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Ireland - EC2  ec2-eu-west-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 London, UK - EC2  London_EC2  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Paris - EC2  ec2-eu-west-3  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Amsterdam, NL - GCE  gce-europe-west4  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Edge
 Frankfurt, Germany - EC2  ec2-eu-central-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Milan, Italy - EC2  ec2-eu-south-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Stockholm, Sweden - EC2  ec2-eu-north-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Cape Town, South Africa - EC2  ec2-af-south-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Bahrain - EC2  ec2-me-south-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Dubai, UAE - Azure  azure-uae-north  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Mumbai, India - EC2  ap-south-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Bangkok, Thailand - Tencent  tencent-bangkok  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Singapore - EC2  ec2-ap-southeast-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Jakarta, Indonesia - GCE  gce-asia-southeast2  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Hong Kong, China - EC2  ec2-ap-east-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Shanghai, China - Tencent  tencent-shanghai  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Beijing, China - Tencent  tencent-beijing  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Ningxia, China - EC2  ec2-cn-northwest-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Taiwan - GCE  gce-asia-east1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Seoul, Korea - EC2  ec2-ap-northeast-2  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Tokyo, Japan - EC2  ec2-ap-northeast-1  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Osaka, Japan - EC2  ec2-ap-northeast-3  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Sydney, Australia - EC2  ec2-ap-southeast-2  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave,Edge
 Melbourne, Australia - Azure  azure-australia-southeast  Chrome,Chrome Beta,Chrome Canary,Firefox,Firefox Nightly,Firefox ESR,Brave
 Los Angeles, CA- M1 Mac Mini  LosAngeles_M1MacMini  Chrome,Chrome Beta,Chrome Dev,Chrome Canary,Safari,Firefox
 New York, NY- M1 Mac Mini  NewYork_M1MacMini  Chrome,Chrome Beta,Chrome Dev,Chrome Canary,Safari,Firefox

 

  1. 요청 매개변수:
    • URL: https://www.google.com
    • location:browser.connectivity: 지역별 브라우저 연결 설정
    • private: 1 (비공개 테스트 설정)
    • video: 1 (비디오 캡처 활성화)
    • 요청 ID: json (결과를 JSON 형식으로 받기 위해)
    • tcpdump: 1 (TCP 덤프 활성화)
    • pngss: 1 (스크린샷 활성화)
    • timeline: 1 (타임라인 데이터 활성화)
  2. 지역 목록:
    • ec2-us-east-1:Chrome.Native
    • gce-us-west3:Chrome.Native
    • ec2-us-west-1:Chrome.Native
    • ec2-ca-central-1:Chrome.Native
    • … (다른 지역도 포함)
  3. PHP 코드:
    <?php
    $url = 'https://www.google.com';
    $locations = [
        'ec2-us-east-1:Chrome.Native',
        'gce-us-west3:Chrome.Native',
        'ec2-us-west-1:Chrome.Native',
        'ec2-ca-central-1:Chrome.Native',
        // 다른 지역도 추가
    ];
    $private = 1;
    $video = 1;
    $requestId = 'json';
    $tcpdump = 1;
    $pngss = 1;
    $timeline = 1;
    
    // CSV 파일로 저장할 데이터 배열 초기화
    $csvData = [['Location', 'From', 'Fully Loaded (ms)']];
    
    foreach ($locations as $location) {
        $apiUrl = "https://www.webpagetest.org/runtest.php?url=$url&location=$location&private=$private&video=$video&requestId=$requestId&tcpdump=$tcpdump&pngss=$pngss&timeline=$timeline";
    
        // API 호출
        $response = file_get_contents($apiUrl);
    
        // 결과 확인
        $result = json_decode($response, true);
        if ($result['statusCode'] === 200) {
            $testId = $result['data']['testId'];
            echo "Test submitted successfully for location $location. Test ID: $testId\n";
    
            // 테스트 상태 확인을 위한 URL
            $testStatusUrl = "https://www.webpagetest.org/testStatus.php?test=$testId";
    
            // 테스트 결과를 가져올 URL
            $jsonResultUrl = "https://www.webpagetest.org/jsonResult.php?test=$testId";
    
            // 테스트 상태 확인
            while (true) {
                $statusResponse = file_get_contents($testStatusUrl);
                $statusData = json_decode($statusResponse, true);
    
                if ($statusData['statusText'] === 'Test Complete') {
                    // 테스트가 완료된 경우 결과를 가져옴
                    $resultResponse = file_get_contents($jsonResultUrl);
                    $resultData = json_decode($resultResponse, true);
    
                    // CSV 데이터에 추가
                    $csvData[] = [$resultData['location'], $resultData['from'], $resultData['average']['firstView']['fullyLoaded']];
                    break;
                } else {
                    echo "Test is not yet complete for location $location. Status: {$statusData['statusText']}\n";
                    sleep(60); // 1분 대기
                }
            }
        } else {
            echo "Error submitting test for location $location. Status code: {$result['statusCode']}\n";
        }
    }
    
    // CSV 파일로 저장
    $csvFileName = 'test_results.csv';
    $csvFile = fopen($csvFileName, 'w');
    foreach ($csvData as $row) {
        fputcsv($csvFile, $row);
    }
    fclose($csvFile);
    
    echo "All tests completed successfully. Results saved to $csvFileName";
    ?>
     
    • $apiUrl에 WebPageTest API 엔드포인트와 매개변수를 설정합니다.
    • file_get_contents를 사용하여 API를 호출하고 결과를 받아옵니다.
    • 결과가 성공적으로 제출되면 테스트 ID를 출력합니다.

테스트 결과가 완료 됨을 확인 하여 csv엑셀로 저장하는 소스 입니다.

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."
Posted by 프리스케이터