I'm trying to do initial install of a BigCommerce draft app for oAuth access to api using the official Bigcommerce php library.
For some reason no matter what I do I get null back from a post to BigCommerce api. Can anyone see anything that could be causing this?
Thanks for any advice
<?php
require_once ('vendor/autoload.php');
use Bigcommerce\Api\Connection as Connection;
use Bigcommerce\Api\Client as Bigcommerce;
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$client_id = "*******";
$client_secret = "*******";
if (count($_GET)) {
$code = $_GET['code'];
$context = $_GET['context'];
$scope = $_GET['scope'];
$url = "https://login.bigcommerce.com/oauth2/token";
$connection = new Connection();
$connection->useUrlencoded();
$connection->verifyPeer(false);
$response = $connection->post($url, array(
"client_id" => $client_id,
"client_secret" => $client_secret,
"redirect_uri" => "https://www.*******.com/bc-auth.php",
"grant_type" => "authorization_code",
"code" => $code,
"scope" => $scope,
"context" => $context));
if (is_null($response)) {
print "Last Error:\n";
print "<pre>";
print_r(Bigcommerce::getLastError());
print "</pre>";
exit();
}
$token = $response->access_token;
die($token); // this is just for testing
}
Try making your own POST request via cURL, papi..
Removing and inserting it instead of this code: