Bigcommerce API start - bigcommerce

first of all, sorry for this silly question
but I am new to use big commerce API and I searched and found many threads but not works for me .
the composer created a directory vendor
then its root I have to create a file index.php and put this code but it's showing me the blank page
<?php
require 'vendor/autoload.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
Bigcommerce::verifyPeer(false);
$ping = Bigcommerce::getTime();
if ($ping) echo $ping->format('H:i:s');
$filter = array("page" => 3, "limit" => 30);
$products = Bigcommerce::getProducts($filter);
?>
Please, someone, explain all steps with the easy understandable process ?
Sometimes it's giving
Fatal error: Class 'Bigcommerce_Api' not found in C:\xampp\htdocs\bigcommerceapi\index.php on line 30
I followed this community
https://c9.io/oschino/bigcommerce-api-php-oauth
when I clicking the single file link it's showing 404 not found where from I can download big commerce.php file
Also, I want to know if composer created a whole PHP API then is it it is necessary to download big commerce PHP API from Github ?
I have checked the folder structure and files are same in vendor folder and big commerce git hub files.
Please help

I got solution the bigcoomerce store URL call process is now changed
I changed
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
to like this
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com',
'username' => 'xxxx',
'api_key' => 'xxxx'
));

Related

Web push notification example with PHP backend

I am looking for an example for web push notification with JS code and PHP backend. Can anyone share example code or a tutorial?
Here's a basic example that uses web-push-php : https://github.com/Minishlink/web-push-php-example
Main PHP code is:
<?php
require __DIR__ . '/vendor/autoload.php';
use Minishlink\WebPush\WebPush;
$auth = array(
'VAPID' => array(
'subject' => 'https://github.com/Minishlink/web-push-php-example/',
'publicKey' => 'BCmti7ScwxxVAlB7WAyxoOXtV7J8vVCXwEDIFXjKvD-ma-yJx_eHJLdADyyzzTKRGb395bSAtxlh4wuDycO3Ih4',
'privateKey' => 'HJweeF64L35gw5YLECa-K7hwp3LLfcKtpdRNK8C_fPQ', // in the real world, this would be in a secret file
),
);
$webPush = new WebPush($auth);
$res = $webPush->sendNotification(
$subscription['endpoint'],
"Hello!", // payload
$subscription['key'],
$subscription['token'],
true // flush
);
// handle eventual errors here, and remove the subscription from your server if it is expired
Hope this helps :)

git ignore Yii database details

Some of the details in the main.php needed by all application instances (URL details) and some details will be specific to each application instance (database details).
Is there any idea to separate the database details from protected/config/main.php?
Just include the shared configuration from another PHP file:
main.php:
return array
(
....
'components' => array
(
'db' => include('sharedDatabaseConfiguration.php');
)
);
sharedDatabaseConfiguration.php:
return array('host' => ...);
You might have to add a path or something, depending where the file is stored.
Edit: Btw, Yii also has a fancy CMap::mergeArray() function that can do something similar (in case you want to "augment" the contents of a single config file with that from another one. Look at the default generated console.php for an example of that.
You can find an idea here: Manage application configuration in different modes .
Basically it works by importing a different PHP file (your db configuration) and merging the includedarrays:
<?php
return CMap::mergeArray(
require(dirname(__FILE__).'/db-config.php'),
array(
'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name' => 'Page Title',
...
)
);
?>
You can use separate configuration file (e.g. protected/config/production.php), that is based on your main configuration file and that overrides some settings using CMap::mergeArray as this answer suggests:
return CMap::mergeArray(
require(dirname(__FILE__) . '/main.php'),
array(
'components' => array(
'db' => array(
'connectionString' => '...',
'username' => '...',
'password' => '...',
),
),
)
);
Then you can add protected/config/production.php to .gitignore.

How to separate Cakephp session and Yii session

I have a Cakephp application and Yii application running on the same server. And their session config are
Cakephp:
Configure::write('Session', array(
'defaults' => 'php',
'ini' => array(
'session.cookie_path' => '/cakephp_app',
),
'cookie' => 'PHPSESSID'
));
Yii:
'session' => array(
'autoStart' => true,
'timeout' => 5400,
'sessionName' => 'YIIAPP',
)
I supposed their session will be separated, but the result is negative.
Since the cakephp app is already in production, so what can I do to separate the Yii session from the cakephp session?
And can anyone tell me how come my Yii is still using the PHPSESSID session, rather than then 'YIIAPP' session?
I've tested this and adding:
'sessionName' => 'YiiAPP'
worked first time for me.
However, I then added
session_start()
To my index.php file - and this then shows the PHPSESSID. So I suspect somewhere in your code you are using session_start() - which Yii doesn't need. It starts its own session automatically.

bigcommerce api returning blank results

I have downloaded the bigcommerce API and created a test script using the get time sample.
I get a blank response & no error:
My test code is just:
<?php
require 'bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://storeurl.mybigcommerce.com',
'username' => 'apiusername',
'api_key' => 'token'
));
Bigcommerce::setCipher();
Bigcommerce::verifyPeer(false);
$ping = Bigcommerce::getTime();
if ($ping) echo $ping->format('H:i:s');
?>
Can you assist as to why the result is blank ?
I think your cipher is incorrect.
Please look at the docs http://developer.bigcommerce.com/quickstarts/php
Bigcommerce::setCipher('RC4-SHA')

Using Bundles in Laravel Migrations

I want to use sentry 1.x with Laravel 3.x in the migrations I use, but when I try to migrate I get this error:
PHP Fatal error: Class 'Sentry' not found in /var/www/laravel.dev/application/migrations/2013_03_06_183713_add_user_to_database.php on line 34
This is what I try to do in function up():
$user_id = Sentry::user()->create(array(
'email' => 'admin#test.com',
'password' => 'testpass',
'metadata' => array(
'first_name' => 'Test',
'last_name' => 'Test'
)
));
What am I missing ?
p.s: I know having the password in PHP is insecure, this is just a test environment.
Thanks,
You need to start the bundle.
Bundle::start( 'sentry' );
Add 'Cartalyst\Sentry\SentryServiceProvider' to the list of service providers in app/config/app.php