Created
December 3, 2018 08:23
-
-
Save jyokyoku/3f9025c81ce96fe3deb1e1c9e4c2a0c7 to your computer and use it in GitHub Desktop.
カラーミーショップ商品取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define( 'ACCESS_TOKEN', '{アクセストークンを入れます}' ); | |
$query_str = http_build_query( array( | |
'category_id_big' => '15', // カテゴリーID | |
'name' => '商品名', // 取得する商品名のLIKE検索 | |
'display_state' => 'showing', // 表示中の商品だけを取得 | |
'limit' => '5', // 最大取得件数 | |
) ); | |
$url = 'https://api.shop-pro.jp/v1/products.json?' . $query_str; | |
$response = wp_remote_get( $url, array( | |
'headers' => array( | |
'Authorization' => 'Bearer ' . ACCESS_TOKEN | |
) | |
) ); | |
if ( wp_remote_retrieve_response_code( $response ) === '200' ) { | |
$json = wp_remote_retrieve_body( $response ); | |
var_dump( $json ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment