Blockchain code Metaverse VR

Unity×VR×Blockchain(331)

スポンサーリンク

//tips

//基本情報理解

安全余裕率は「(売上高-損益分岐点売上高)/売上高」で求められる指標で、値が高いほど経営が安全であると言える指標とのこと。

下請代金支払遅延等防止法では、下請事業者が不利益を被ることがないように「受領拒否の禁止」や「返品禁止」などが定められている。

技適マークは電波法令で定められている技術基準に適合している無線機であることを証明するマークであり、個々の無線機につけられているもの。

//unity/shopify

Index.phpの方でsql文を挿入し、試しにデータベース連動ができているかを確かめることにする。

$shopify=$_GET;
//echo print_r($shopify);

$demo_shop="myshop";
$demo_token="12345";

$dsn='mysql:dbname=shops;host=localhost;cahrset=utf8';
$user='root';
$password='';
$dbh=new PDO($dsn,$user,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql='INSERT INTO shops(shop_url,access_token,install_date) VALUE (?,?,NOW())';
$stmt=$dbh->prepare($sql);
$data[]=$demo_shop;
$data[]=$demo_token;

$dbh=null;

データベースにshop_url,access_token,install_dateが追加されていない。print $demo_token;を最終文に追加したらきちんと画面に表示はされたので、再度入力内容を更新する。

$stmt->execute($data);が抜けてたので追加と入力データに安全策を施した。

$demo_shop="myshop";
$demo_token="12345";

$demo_shop=htmlspecialchars($demo_shop,ENT_QUOTES,'UTF-8');
$demo_token=htmlspecialchars($demo_token,ENT_QUOTES,'UTF-8');

$dsn='mysql:dbname=shops;host=localhost;cahrset=utf8';
$user='root';
$password='';
$dbh=new PDO($dsn,$user,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql='INSERT INTO shops(shop_url,access_token,install_date) VALUE (?,?,NOW())';
$stmt=$dbh->prepare($sql);
$data[]=$demo_shop;
$data[]=$demo_token;
$stmt->execute($data);

$dbh=null;
print $demo_token;

これによりshopsテーブルにid,shop_url,access_token,install_dateが追加されることが確認できた。

ここからはgenerate_token.phpの機能を読み解きつつ、適切な場所に先のsqlのINSERTを入れられるようにする。

<?php

// Get our helper functions
require_once("inc/functions.php");

// Set variables for our request
$api_key = "1cec4934ef5ad8824bad30178932dab9";
$shared_secret = “…..”;
$params = $_GET; // Retrieve all request parameters
$hmac = $_GET['hmac']; // Retrieve HMAC request parameter

$params = array_diff_key($params, array('hmac' => '')); // Remove hmac from params
ksort($params); // Sort params lexographically

$computed_hmac = hash_hmac('sha256', http_build_query($params), $shared_secret);

// Use hmac data to check that the response is from Shopify or not
if (hash_equals($hmac, $computed_hmac)) {

// Set variables for our request
$query = array(
"client_id" => $api_key, // Your API key
"client_secret" => $shared_secret, // Your app credentials (secret key)
"code" => $params['code'] // Grab the access key from the URL
);

// Generate access token URL
$access_token_url = "https://" . $params['shop'] . "/admin/oauth/access_token";

// Configure curl client and execute request
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $access_token_url);
curl_setopt($ch, CURLOPT_POST, count($query));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
$result = curl_exec($ch);
curl_close($ch);

// Store the access token
$result = json_decode($result, true);
$access_token = $result['access_token'];

// Show the access token (don't do this in production!)
echo $access_token;

} else {
// Someone is trying to be shady!
die('This request is NOT from Shopify!');
}

まずはrequire_once("inc/functions.php”);でinc/functions.phpに行っている理由から確認していく。

人気の記事

1

皆さん、ついに、エアラインでも、サブスクリプションが始まったのはご存じですか? まだ実験段階ですが、ANAが、定額全国住み放題サービスを提供する「ADDress」と組んで、国内線を4回まで定額利用可能 ...

2

無料でネットショップを開けるアプリとして多くの人に驚きを与えたBASE株式会社が、2019年10月25日東証マザーズに上場しました。2020年2月時点で90万店を超えるショップを抱えるまでに成長してい ...

3

2011年にサービスを開始してから圧倒的な成長率を誇るインテリア通販サイト 【FLYMEe/フライミー】を皆さんご存じでしょうか。 「自分のイメージするインテリア、本当に欲しいインテリアがどこにあるの ...

4

ついに、noteの月間アクティブユーザー数が4400万人(2020年3月時点)に到達しました。 そもそも、「note」とは、クリエイターが、文章やマンガ、写真、音声を投稿することができ、ユーザーはその ...

5

ボードゲームカフェが1日2回転で儲かるという記事をみつけたので興味を持ち、調べてみました。 まずは、需要がどれくらいあるのか、市場のようすからみていきましょう。 世界最大のボードゲーム市場はドイツで、 ...

-Blockchain, code, Metaverse, VR
-, ,

Copyright© BUSINESS HUNTER , 2023 All Rights Reserved Powered by AFFINGER5.