execute() public method

Executes API
public execute ( string $operation, array $parameter = [], string $version = null )
$operation string The operation name
$parameter array The request parameter
$version string The API version
Esempio n. 1
0
 private static function search($keyword)
 {
     if ($output = self::fetchCache($keyword)) {
         return $output;
     }
     $options = get_option('wp_rakuten_options');
     // 楽天商品検索
     $client = new RakutenRws_Client();
     $client->setApplicationId($options['developer_id']);
     $client->setAffiliateId($options['affiliate_id']);
     $response = $client->execute('IchibaItemSearch', array('keyword' => $keyword, 'availability' => '1', 'sort' => '+affiliateRate', 'hits' => 1));
     $html = '';
     foreach ($response as $item) {
         if ((int) $item['imageFlag'] === 1) {
             $html .= "<p>";
             $html .= "<a href=\"{$item['affiliateUrl']}\">";
             $html .= "<img src=\"{$item['mediumImageUrls'][0]['imageUrl']}\"><br />";
             $html .= "{$item['itemName']}</a>";
             $html .= "</p>";
         }
     }
     $output = '<!-- Rakuten Plugin Start -->';
     $output .= $html;
     $output .= '<!-- Rakuten Plugin End -->';
     self::createCache($keyword, $output);
     return $output;
 }
 private function search_ranking($search_parms)
 {
     $rakuten_client = new RakutenRws_Client();
     $rakuten_client->setApplicationId($this->rakuten_apuri_id);
     $rakuten_client->setAffiliateId($this->afferiate_id);
     $response = $rakuten_client->execute('IchibaItemRanking', $search_parms);
     if ($response->isOk()) {
         //$this->Session['search_item_result'] = $response;
         $this->Session['search_item_result'] = $this->convArr_RakutenApiResponce($response);
         $this->Session['search_item_result_max_page'] = $response['pageCount'];
         $this->Session['search_item_result_now_page'] = $response['page'];
     } else {
         header('Content-Type: application/json');
         echo json_encode(array('error' => 'search_error', 'error_message' => $response->getMessage()));
         exit;
     }
 }
Esempio n. 3
0
if ($scheme == 'http' && $port == ':80' || $scheme == 'https' && $port == ':443') {
    $port = '';
}
$url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $port . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
// Clientインスタンスを生成
$rwsclient = new RakutenRws_Client();
// アプリIDをセット
$rwsclient->setApplicationId(RAKUTEN_APP_ID);
// Secretをセット
$rwsclient->setSecret(RAKUTEN_APP_SECRET);
// アフィリエイトIDをセット (任意)
$rwsclient->setAffiliateId(RAKUTEN_APP_AFFILITE_ID);
// 認証時リダイレクトURLをセット
$rwsclient->setRedirectUrl($url);
// リクエストに 'code' があった場合、アクセストークンを取得し
// API を実行します。
// If a request has 'code', get access_token and execute API
if ($_GET['code']) {
    // アクセストークンを取得します。
    if ($rwsclient->fetchAccessTokenFromCode()) {
        // Bookmark追加APIを実行します (http://webservice.rakuten.co.jp/api/favoritebookmarkadd/)
        $response = $rwsclient->execute('FavoriteBookmarkAdd', array('itemCode' => $_GET['itemCode']));
    }
    // 検索画面へ戻ります
    header('Location: index.php?keyword=' . urlencode($keyword) . '&page=' . urlencode($page) . '&m=1');
    exit;
}
// パラメーターに 'code' がない場合は、rakuten_favoritebookmark_update scope の
// 承認画面へ遷移します
header('Location: ' . $rwsclient->getAuthorizeUrl('rakuten_favoritebookmark_update'));
exit;
Esempio n. 4
0
$page = 1;
if (isset($_GET['keyword'])) {
    $keyword = $_GET['keyword'];
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    // Clientインスタンスを生成 Make client instance
    $rwsclient = new RakutenRws_Client();
    // アプリIDをセット Set Application ID
    $rwsclient->setApplicationId(RAKUTEN_APP_ID);
    // アフィリエイトIDをセット (任意) Set Affiliate ID (Optional)
    $rwsclient->setAffiliateId(RAKUTEN_APP_AFFILITE_ID);
    // プロキシの設定が必要な場合は、ここで設定します。
    // If you want to set proxy, please set here.
    // $rwsclient->setProxy('proxy');
    // 楽天市場商品検索API2 で商品を検索します
    // Search by IchibaItemSearch (http://webservice.rakuten.co.jp/api/ichibaitemsearch/)
    $response = $rwsclient->execute('IchibaItemSearch', array('keyword' => $keyword, 'page' => $page, 'hits' => 9));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Rakuten Web Service SDK - Sample</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<header>
<h1><a href="index.php">Rakuten Web Service SDK - Sample</a></h1>
</header>

<nav class="search-form">