1

我正试图卷入 bigcommerce 网络钩子……尽管我遇到了一个我无法弄清楚的错误。

有任何想法吗?

JSON::ParserError at /token

https://developer.bigcommerce.com/docs/api/webhooks/event_triggers https://developer.bigcommerce.com/docs/api/webhooks/quickstart

<?php

    //set POST variables
    $url = 'https://hooks-beta.bigcommerce.com/token';
    $fields = array(
    "client_id"=>"client_id_goes_here",
    "client_secret"=>"client_secret_goes_here",
    "user"=>"demo",
    "token"=>"token_goes_here",
    "store_domain"=>"https://domain_goes_here.mybigcommerce.com/api/v2"
        );

    //open connection
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); 
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_TIMEOUT, 30); 

    $result = curl_exec($ch); 
        if ($result === false) {
            echo '<textarea>'.curl_error($ch).'</textarea>'; 
        } else {
            echo "<textarea>".$result."</textarea>";
        }
        curl_close($ch);
    ?>
4

1 回答 1

1

我能够通过 json_encoding 我的数组来解决我的问题。

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
于 2013-07-23T14:30:25.363 回答