Skip to content

Instantly share code, notes, and snippets.

@jyokyoku
Created December 3, 2018 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyokyoku/3f9025c81ce96fe3deb1e1c9e4c2a0c7 to your computer and use it in GitHub Desktop.
Save jyokyoku/3f9025c81ce96fe3deb1e1c9e4c2a0c7 to your computer and use it in GitHub Desktop.
カラーミーショップ商品取得
<?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