ابدأ التعلم

محرر الترميز


Success Response


header('Content-Type: application/json');
$response = array(
    'status' => 'success',
    'message' => 'API endpoint reached successfully'
);
echo json_encode($response);
            

Error Response


header('Content-Type: application/json');
$errorMessage = 'API endpoint encountered an error';
$additionalInfo = array(
    'error_code' => 5001,
    'error_details' => 'Detailed description of the error encountered.',
    'suggested_action' => 'Please check your request parameters and try again.',
    'contact' => array(
        'name' => 'Support Team',
        'email' => 'support@example.com',
        'phone' => '+1-800-123-4567'
    )
);
$response = array(
    'status' => 'error',
    'message' => $errorMessage,
    'timestamp' => time(), 
    'additional_info' => $additionalInfo
);
echo json_encode($response);