WP REST API에 문자열 파라미터 전달
WP REST API에 정수값을 전달할 수 있습니다.단, 숫자가 아닌 문자를 전달할 수 없습니다.에러가 납니다.
이게 제가 쓰던...
add_action( 'rest_api_init', function () {
register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d+)/(?P<username>\d+)', array(
'methods' => 'POST',
'callback' => 'userCheck',
) );
} );
현악기 다룰 줄 아세요?
내가 직접 찾았어...
사용하다[a-zA-Z0-9-]
대신\d
현악기 있게
add_action( 'rest_api_init', function () {
register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d+)/(?P<number>[a-zA-Z0-9-]+)', array(
'methods' => 'POST',
'callback' => 'userCheck',
) );
} );
이 방법은 효과가 있었습니다./(?P<slug>\w+)
끝점을 정의하려면 아래 코드도 시도해 보십시오.
add_action( 'rest_api_init', function () {
register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d)/(?P<username>\d)', array(
'methods' => 'POST',
'callback' => 'userCheck',
) );
} );
이거 먹어봐, 잘 될 거야
add_action( 'rest_api_init', function () {
register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d+)/(?P<username>\w+)', array(
'methods' => 'POST',
'callback' => 'userCheck',
) );
} );
언급URL : https://stackoverflow.com/questions/41739288/pass-string-parameters-to-wp-rest-api
'programing' 카테고리의 다른 글
외부 설정 방법jQuery를 사용한HTML (0) | 2023.03.05 |
---|---|
채팅 앱 스케일링 - 짧은 폴링과 긴 폴링(AJAX, PHP) (0) | 2023.03.05 |
Wordpress JSON API는 html의 일반 사이트 페이지를 반환합니다.어떻게 하면 JSON을 받을 수 있을까요? (0) | 2023.02.28 |
spread 구문 및 typescript에 새로운 Set() 사용 (0) | 2023.02.28 |
WooCommerce 서브스크립션 - 특정 서브스크립션 관련 주문 ID 가져오기 (0) | 2023.02.28 |