# Prestashop PHP cURLによるGETリクエスト

**URL:** https://forum.ficusonline.com/t/prestashop-php-curl-get/203
**Category:** WEB Design
**Created:** [2018 年 6 月 19 日午前 3:11 UTC](https://forum.ficusonline.com/t/prestashop-php-curl-get/203 "2018-06-19T03:11:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2018 年 6 月 19 日午前 3:11 UTC](https://forum.ficusonline.com/t/prestashop-php-curl-get/203/1 "2018-06-19T03:11:02Z")

</div>

**PHP cURLによるGETリクエスト**

> **[PHP: curl\_setopt - Manual](https://www.php.net/manual/ja/function.curl-setopt.php)**
>
> cURL 転送用オプションを設定する

> <https://stackoverflow.com/questions/17230246/php-curl-get-request-and-requests-body>

**リクエスト先はBloclchaininfoのAPI用アドレス**

> **[Blockchain Developer APIs](https://www.blockchain.com/explorer/api)**
>
> The most popular and trusted block explorer and crypto transaction search engine.

**Blockchaininfo API**

> **[Blockchain Developer APIs](https://www.blockchain.com/explorer/api)**
>
> The most popular and trusted block explorer and crypto transaction search engine.

必要なパラメータは、  
**xpub** - Your xPub (where you would like the payment to be sent)  
**callback\_url** - The callback URL to be notified when a payment is received. Remember to URL Encode the callback url when calling the create method.  
**key** - Your blockchain.info receive payments v2 api key. Request an API key.  
**gap\_limit** - Optional. How many unused addresses are allowed before erroring out.

暗号化されたトークンとカートIDからビットコインアドレスを取得する。  
戻り値にはアドレスとレスポンスコード(200,500など)を含む。

```
public function getNewAddress($token, $cartid)
    {
        $my_xpub = Configuration::get('BLOCKCHAININFOBTC_XPUB_ADDR');
        $my_api_key = Configuration::get('BLOCKCHAININFOBTC_API_KEY');
        $my_callback_url = urlencode($this->context->link->getModuleLink(
            $this->name,
            'callback',
            array('bci_token' => $token,
            'cart_id' => $cartid
            )
        ));
        $root_url = Configuration::get('BLOCKCHAININFOBTC_NEW_ADDRESS_URL');
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $root_url. '?xpub=' .$my_xpub. '&callback=' .$my_callback_url. '&key=' .$my_api_key. '&gap_limit=100');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        $data = curl_exec($ch);
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        $addressObj = Tools::jsonDecode($data);
        if (!isset($addressObj)) {
            $addressObj = new stdClass();
        }
        $addressObj->{'response_code'} = $httpcode;

        return $addressObj;
    }

```
