가능하다면 GitHub 저장소에 문제를 제기해 주세요. 그렇지 않다면 언제든지 저에게 연락해 주세요.
버그 수정이나 잠재적인 변경 사항에 대한 풀 요청을 환영합니다!
이 추가 정보의 맨 아래에는 일부 이벤트 코드 목록과 대략적인 정의가 나와 있습니다.
PHP 8.1 이상이 필요합니다.
Composer를 통해 패키지를 설치하려면:
composer require elliotjreed/royal-mail-tracking
추적 데이터를 가져오는 세 가지 방법을 사용할 수 있습니다.
Events
: 단일 추적 번호에 대한 자세한 정보 및 전체 내역을 제공합니다.Signature
: 서명 데이터(이미지 데이터 포함 - base64로 인코딩된 PNG 또는 SVG)Summary
: 여러 추적 번호에 대한 가장 최근 이벤트입니다.아래에는 각 항목에 대한 세부정보가 예시와 함께 설명되어 있습니다.
오류 처리에 대한 정보는 Events
, Signature
및 Summary
정보 아래에 제공됩니다. Summary
오류는 Events
및 Summary
오류와 다르게 처리되므로 읽어 볼 가치가 있습니다.
$ tracking = ( new ElliotJReed RoyalMail Tracking Events (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 ' ,
true , // Optional, when true (default: true) exceptions will be thrown for tracking errors
true , // Optional, when true (default: true) exceptions will be thrown for technical (eg. 500 HTTP response) errors
' https://api.royalmail.net/mailpieces/v2 ' // Optional , when set the default API endpoint can be overridden (default: ' https://api.royalmail.net/mailpieces/v2 ' )
));
$ signature = ( new ElliotJReed RoyalMail Tracking Signature (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 ' ,
true , // Optional, when true (default: true) exceptions will be thrown for tracking errors
true , // Optional, when true (default: true) exceptions will be thrown for technical (eg. 500 HTTP response) errors
' https://api.royalmail.net/mailpieces/v2 ' // Optional , when set the default API endpoint can be overridden (default: ' https://api.royalmail.net/mailpieces/v2 ' )
));
$ summary = ( new ElliotJReed RoyalMail Tracking Summary (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 ' ,
true , // Optional, when true (default: true) exceptions will be thrown for tracking errors
true , // Optional, when true (default: true) exceptions will be thrown for technical (eg. 500 HTTP response) errors
' https://api.royalmail.net/mailpieces/v2 ' // Optional , when set the default API endpoint can be overridden (default: ' https://api.royalmail.net/mailpieces/v2 ' )
));
이벤트 작업의 동작은 단일 메일 항목에 대한 트랙 기록을 제공하는 것입니다.
제공된 추적 번호에 대한 요약, 서명 메타데이터, 예상 배송 기간 및 이벤트를 반환합니다.
$ tracking = ( new ElliotJReed RoyalMail Tracking Events (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
$ mailPieces = $ tracking -> setTrackingNumber ( ' AB1234567890GB ' )-> getResponse ()-> getMailPieces ();
$ mailPieces -> getMailPieceId (); // 090367574000000FE1E1B
$ mailPieces -> getCarrierShortName (); // RM
$ mailPieces -> getCarrierFullName (); // Royal Mail Group Ltd
$ summary = $ mailPieces -> getSummary ();
$ summary -> getUniqueItemId (); // 090367574000000FE1E1B
$ summary -> getOneDBarcode (); // FQ087430672GB
$ summary -> getProductId (); // SD2
$ summary -> getProductName (); // Special Delivery Guaranteed
$ summary -> getProductDescription (); // Our guaranteed next day service with tracking and a signature on delivery
$ summary -> getProductCategory (); // NON-INTERNATIONAL
$ summary -> getDestinationCountryCode (); // GBR
$ summary -> getDestinationCountryName (); // United Kingdom of Great Britain and Northern Ireland
$ summary -> getOriginCountryCode (); // GBR
$ summary -> getOriginCountryName (); // United Kingdom of Great Britain and Northern Ireland
$ summary -> getLastEventCode (); // EVNMI
$ summary -> getLastEventName (); // Forwarded - Mis-sort
$ summary -> getLastEventDateTime (); // new DateTimeImmutable('2016-10-20T10:04:00+01:00')
$ summary -> getLastEventLocationName (); // Stafford DO
$ summary -> getStatusDescription (); // It is being redirected
$ summary -> getStatusCategory (); // IN TRANSIT
$ summary -> getStatusHelpText (); // The item is in transit
$ summary -> getSummaryLine (); // Item FQ087430672GB was forwarded to the Delivery Office on 2016-10-20.
$ internationalPostalProvider = $ summary -> getInternationalPostalProvider ();
$ internationalPostalProvider -> getUrl (); // https://www.royalmail.com/track-your-item
$ internationalPostalProvider -> getTitle (); // Royal Mail Group Ltd
$ internationalPostalProvider -> getDescription (); // Royal Mail Group Ltd
$ signature = $ mailPieces -> getSignature ();
$ signature -> getRecipientName (); // Elliot
$ signature -> getSignatureDateTime (); // new DateTimeImmutable('2016-10-20T10:04:00+01:00')
$ signature -> getImageId (); // 001234
$ estimatedDelivery = $ mailPieces -> getEstimatedDelivery ();
$ estimatedDelivery -> getDate (); // new DateTimeImmutable('2017-02-20T00:00:00+00:00')
$ estimatedDelivery -> getStartOfEstimatedWindow (); // new DateTimeImmutable('2017-02-20T08:00:00+01:00')
$ estimatedDelivery -> getEndOfEstimatedWindow (); // new DateTimeImmutable('2017-02-20T11:00:00+01:00')
$ events = $ mailPieces -> getEvents ();
$ event = $ events [ 0 ];
$ event -> getEventCode (); // EVNMI
$ event -> getEventName (); // Forwarded - Mis-sort
$ event -> getEventDateTime (); // new DateTimeImmutable('2016-10-20T10:04:00+01:00')
$ event -> getLocationName (); // Stafford DO
$ linkSummary = $ mailPieces -> getLinks ()-> getSummary ();
$ linkSummary -> getHref (); // /mailpieces/v2/summary?mailPieceId=090367574000000FE1E1B
$ linkSummary -> getTitle (); // Summary
$ linkSummary -> getDescription (); // Get summary
$ linkSignature = $ mailPieces -> getLinks ()-> getSignature ();
$ linkSignature -> getHref (); // /mailpieces/v2/090367574000000FE1E1B/signature
$ linkSignature -> getTitle (); // Signature
$ linkSignature -> getDescription (); // Get signature
$ linkRedelivery = $ mailPieces -> getLinks ()-> getRedelivery ();
$ linkRedelivery -> getHref (); // /personal/receiving-mail/redelivery
$ linkRedelivery -> getTitle (); // Redelivery
$ linkRedelivery -> getDescription (); // Book a redelivery
$ tracking = ( new ElliotJReed RoyalMail Tracking Events (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
echo $ tracking -> setTrackingNumber ( ' AB1234567890GB ' )-> asJson ();
Royal Mail 응답을 JSON으로 출력합니다.
{
"errors" : [],
"httpCode" : null ,
"httpMessage" : null ,
"mailPieces" : {
"carrierFullName" : " Royal Mail Group Ltd " ,
"carrierShortName" : " RM " ,
"estimatedDelivery" : {
"date" : " 2017-02-20T00:00:00+00:00 " ,
"endOfEstimatedWindow" : " 2017-02-20T11:00:00+01:00 " ,
"startOfEstimatedWindow" : " 2017-02-20T08:00:00+01:00 "
},
"events" : [
{
"eventCode" : " EVNMI " ,
"eventDateTime" : " 2016-10-20T10:04:00+01:00 " ,
"eventName" : " Forwarded - Mis-sort " ,
"locationName" : " Stafford DO "
}
],
"links" : {
"redelivery" : {
"description" : " Book a redelivery " ,
"href" : " /personal/receiving-mail/redelivery " ,
"title" : " Redelivery "
},
"signature" : {
"description" : " Get signature " ,
"href" : " /mailpieces/v2/090367574000000FE1E1B/signature " ,
"title" : " Signature "
},
"summary" : {
"description" : " Get summary " ,
"href" : " /mailpieces/v2/summary?mailPieceId=090367574000000FE1E1B " ,
"title" : " Summary "
}
},
"mailPieceId" : " 090367574000000FE1E1B " ,
"signature" : {
"imageId" : " 001234 " ,
"recipientName" : " Elliot " ,
"signatureDateTime" : " 2016-10-20T10:04:00+01:00 "
},
"summary" : {
"destinationCountryCode" : " GBR " ,
"destinationCountryName" : " United Kingdom of Great Britain and Northern Ireland " ,
"internationalPostalProvider" : {
"description" : " Royal Mail Group Ltd " ,
"title" : " Royal Mail Group Ltd " ,
"url" : " https://www.royalmail.com/track-your-item "
},
"lastEventCode" : " EVNMI " ,
"lastEventDateTime" : " 2016-10-20T10:04:00+01:00 " ,
"lastEventLocationName" : " Stafford DO " ,
"lastEventName" : " Forwarded - Mis-sort " ,
"oneDBarcode" : " FQ087430672GB " ,
"originCountryCode" : " GBR " ,
"originCountryName" : " United Kingdom of Great Britain and Northern Ireland " ,
"productCategory" : " NON-INTERNATIONAL " ,
"productDescription" : " Our guaranteed next day service with tracking and a signature on delivery " ,
"productId" : " SD2 " ,
"productName" : " Special Delivery Guaranteed " ,
"statusCategory" : " IN TRANSIT " ,
"statusDescription" : " It is being redirected " ,
"statusHelpText" : " The item is in transit " ,
"summaryLine" : " Item FQ087430672GB was forwarded to the Delivery Office on 2016-10-20. " ,
"uniqueItemId" : " 090367574000000FE1E1B "
}
},
"moreInformation" : null
}
$ tracking = ( new ElliotJReed RoyalMail Tracking Signature (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
$ mailPieces = $ tracking -> setTrackingNumber ( ' AB1234567890GB ' )-> getResponse ()-> getMailPieces ();
$ mailPieces -> getMailPieceId (); // 090367574000000FE1E1B
$ mailPieces -> getCarrierShortName (); // RM
$ mailPieces -> getCarrierFullName (); // Royal Mail Group Ltd
$ signature = $ mailPieces -> getSignature ();
$ signature -> getRecipientName (); // Elliot
$ signature -> getSignatureDateTime (); // new DateTimeImmutable('2017-03-30T16:15:00+01:00')
$ signature -> getImageId (); // 001234
$ signature -> getOneDBarcode (); // FQ087430672GB
$ signature -> getHeight (); // 530
$ signature -> getWidth (); // 660
$ signature -> getUniqueItemId (); // 090367574000000FE1E1B
$ signature -> getImageFormat (); // image/svg+xml
$ signature -> getImage (); // <svg></svg>
$ events = $ mailPieces -> getLinks ()-> getEvents ();
$ events -> getHref (); // /mailpieces/v2/FQ087430672GB/events
$ events -> getTitle (); // Events
$ events -> getDescription (); // Get events
$ linkSummary = $ mailPieces -> getLinks ()-> getSummary ();
$ linkSummary -> getHref (); // /mailpieces/v2/summary?mailPieceId=090367574000000FE1E1B
$ linkSummary -> getTitle (); // Summary
$ linkSummary -> getDescription (); // Get summary
$ tracking = ( new ElliotJReed RoyalMail Tracking Signature (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
echo $ tracking -> setTrackingNumber ( ' AB1234567890GB ' )-> asJson ();
Royal Mail 추적 응답을 JSON으로 출력합니다.
{
"errors" : [],
"httpCode" : null ,
"httpMessage" : null ,
"mailPieces" : {
"carrierFullName" : " Royal Mail Group Ltd " ,
"carrierShortName" : " RM " ,
"links" : {
"events" : {
"description" : " Get events " ,
"href" : " /mailpieces/v2/FQ087430672GB/events " ,
"title" : " Events "
},
"summary" : {
"description" : " Get summary " ,
"href" : " /mailpieces/v2/summary?mailPieceId=090367574000000FE1E1B " ,
"title" : " Summary "
}
},
"mailPieceId" : " 090367574000000FE1E1B " ,
"signature" : {
"height" : 530 ,
"image" : " <svg></svg> " ,
"imageFormat" : " image/svg+xml " ,
"imageId" : " 001234 " ,
"oneDBarcode" : " FQ087430672GB " ,
"recipientName" : " Elliot " ,
"signatureDateTime" : " 2017-03-30T16:15:00+01:00 " ,
"uniqueItemId" : " 090367574000000FE1E1B " ,
"width" : 660
}
},
"moreInformation" : null
}
요약 작업의 동작은 고객이 메일 항목에 대한 최신 추적 데이터를 얻을 수 있도록 하는 것입니다.
이 작업은 요청에 제공된 하나 이상의 추적 번호 요약을 반환합니다.
이 작업에서는 ->setTrackingNumbers()
메서드에 최대 30개의 추적 번호만 제공할 수 있습니다(예: ->setTrackingNumbers(['AB0123456789GB', 'CD0123456789GB'])
).
$ summary = ( new ElliotJReed RoyalMail Tracking Summary (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
$ mailPieces = $ summary -> setTrackingNumbers ( ' AB1234567890GB ' , ' CD1234567890GB ' )-> getResponse ()-> getMailPieces ();
$ firstMailPieces = $ mailPieces [ 0 ];
$ firstMailPieces -> getMailPieceId (); // 090367574000000FE1E1B
$ firstMailPieces -> getCarrierShortName (); // RM
$ firstMailPieces -> getCarrierFullName (); // Royal Mail Group Ltd
$ summary = $ firstMailPieces -> getSummary ();
$ summary -> getUniqueItemId (); // 090367574000000FE1E1B
$ summary -> getOneDBarcode (); // FQ087430672GB
$ summary -> getProductId (); // SD2
$ summary -> getProductName (); // Special Delivery Guaranteed
$ summary -> getProductDescription (); // Our guaranteed next day service with tracking and a signature on delivery
$ summary -> getProductCategory (); // NON-INTERNATIONAL
$ summary -> getDestinationCountryCode (); // GBR
$ summary -> getDestinationCountryName (); // United Kingdom of Great Britain and Northern Ireland
$ summary -> getOriginCountryCode (); // GBR
$ summary -> getOriginCountryName (); // United Kingdom of Great Britain and Northern Ireland
$ summary -> getLastEventCode (); // EVNMI
$ summary -> getLastEventName (); // Forwarded - Mis-sort
$ summary -> getLastEventDateTime (); // new DateTimeImmutable('2016-10-20T10:04:00+01:00')
$ summary -> getLastEventLocationName (); // Stafford DO
$ summary -> getStatusDescription (); // It is being redirected
$ summary -> getStatusCategory (); // IN TRANSIT
$ summary -> getStatusHelpText (); // The item is in transit
$ summary -> getSummaryLine (); // Item FQ087430672GB was forwarded to the Delivery Office on 2016-10-20.
$ internationalPostalProvider = $ summary -> getInternationalPostalProvider ();
$ internationalPostalProvider -> getUrl (); // https://www.royalmail.com/track-your-item
$ internationalPostalProvider -> getTitle (); // Royal Mail Group Ltd
$ internationalPostalProvider -> getDescription (); // Royal Mail Group Ltd
$ events = $ firstMailPieces -> getLinks ()-> getEvents ();
$ events -> getHref (); // /mailpieces/v2/FQ087430672GB/events
$ events -> getTitle (); // Events
$ events -> getDescription (); // Get events
$ error = $ firstMailPieces -> getError ();
$ error -> getErrorCode (); // E1142
$ error -> getErrorDescription (); // Barcode reference $mailPieceId isn't recognised
$ error -> getErrorCause (); // A mail item with that barcode cannot be located
$ error -> getErrorResolution (); // Check barcode and resubmit
$ summary = ( new ElliotJReed RoyalMail Tracking Summary (
new GuzzleHttp Client (),
' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee ' ,
' 12345678901234567890123456789012345678901234567890 '
));
echo $ summary -> asJson ();
Royal Mail 응답을 JSON으로 출력합니다.
{
"errors" : [],
"httpCode" : null ,
"httpMessage" : null ,
"mailPieces" : [
{
"carrierFullName" : " Royal Mail Group Ltd " ,
"carrierShortName" : " RM " ,
"error" : {
"errorCause" : " A mail item with that barcode cannot be located " ,
"errorCode" : " E1142 " ,
"errorDescription" : " Barcode reference mailPieceId is not recognised " ,
"errorResolution" : " Check barcode and resubmit "
},
"links" : {
"events" : {
"description" : " Get events " ,
"href" : " /mailpieces/v2/FQ087430672GB/events " ,
"title" : " Events "
}
},
"mailPieceId" : " 090367574000000FE1E1B " ,
"summary" : {
"destinationCountryCode" : " GBR " ,
"destinationCountryName" : " United Kingdom of Great Britain and Northern Ireland " ,
"internationalPostalProvider" : {
"description" : " Royal Mail Group Ltd " ,
"title" :