bigcommerce / bigcommerce-api-php

Connect PHP applications with the Bigcommerce Platform
https://developer.bigcommerce.com
MIT License
143 stars 186 forks source link

Class "Bigcommerce\Api\Client" not found #289

Closed mareeshwarantcs closed 1 year ago

mareeshwarantcs commented 1 year ago

When try to connect the bigcommerce api, i faced the issue like this, plz help me about this issue

Expected behavior

Connect BigCommerce with Laravel 8.5

Actual behavior

Issue - https://nimb.ws/OSuC9t

Steps to reproduce behavior

public function test(Request $request){ $object = new \stdClass(); $object->client_id = 's4q6oeuf3kvc5jvjfg6grsq0y00w'; $object->client_secret = '3a687f024482cb1193cc2a7c087df6a20133407749635e8446829a281a92'; $object->redirect_uri = "https://enterpriseapplicationdevelopers.com/index.php/oauth"; $object->code = $request->get('code'); $object->context = $request->get('context'); $object->scope = $request->get('scope');

    $authTokenResponse = Bigcommerce::getAuthToken($object);
    print_r($authTokenResponse);exit; // Here we faced the issue

    Bigcommerce::configure([
        'store_url' => 'https://vape-craft-inc-s8.mybigcommerce.com/',
        'username'  => 'admin',
        'api_key'   => '7fmcrroxhhrnoztyegoqm3ydqri7jjb'
    ]);

    $ping = Bigcommerce::getTime();

    if ($ping) echo $ping->format('H:i:s');
}
TomA-R commented 1 year ago

Hi @mareeshwarantcs,

We've tested this locally without problems (Laravel v8.5.24 and 8.6.12). After running composer require bigcommerce/api, the class Bigcommerce\Api\Client was found. Do you have any details on how to reproduce this?

mareeshwarantcs commented 1 year ago

Thanks for your quickest response.

Once i update the composer that error gone. Now i am facing other issue. Ref: https://nimb.ws/OAI6mk

My code is

<?php namespace App\Http\Controllers; use Bigcommerce\Api\Client as Bigcommerce; use Illuminate\Http\Response; use Illuminate\Http\Request;

class AppController extends Controller {

public function test(Request $request){

    $object = new \stdClass();
    $object->client_id = 's4q6oeuf3p3kvc5jvjfgy6grs0y00w';
    $object->client_secret = '3a687f024482cb1193cc2a7c087df6a201334083749635e8446829a281fca92';
    $object->redirect_uri = "https://zamplebox.enterpriseapplicationdevelopers.com/index.php/oauth";
    $object->code = $request->get('code');
    $object->context = $request->get('context');
    $object->scope = $request->get('scope');

    $authTokenResponse = Bigcommerce::getAuthToken($object);
    // print_r($authTokenResponse);exit; // Here authTokenResponse not displayed

    $ping = Bigcommerce::getTime();

    if ($ping) echo $ping->format('H:i:s');
}

}

?>

Kindly help me to resolve this. Thanks once again!

TomA-R commented 1 year ago

Thanks for reporting, @mareeshwarantcs. Turns out Bigcommerce::getTime(); didn't work. This should be fixed now if you update this library.