PHP code example of davalb / php-openbazaar-api

1. Go to this page and download the library: Download davalb/php-openbazaar-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davalb / php-openbazaar-api example snippets



$service = OpenBazaar\ClientFactory::factory([
		'base_url' => 'http://your_ip_or_domain_here:18469/',
	]
);
$response = $service->login([
	'username' => 'your_username_here',
	'password' => 'your_password_here',
]);
// get Profile will return your profile info
$result = $service->getProfile();
// get Listings for the store with the given guid
$result = $service->getListings([
	'guid' => 'a06aa22a38f0e62221ab74464c311bd88305f88c'
]);
// follow another page
$result = $service->follow(
	['guid' => 'a06aa22a38f0e62221ab74464c311bd88305f88c']
);
// change your username
$result = $service->changeProfile(
	['name' => 'New Name']
);
// set social account
$result = $service->createSocialAccount([
    'account_type' => 'twitter',
    'username' => 'user',
]);

// upload an image
$imageurl = "https://placekitten.com/200/300";
$imagedata = file_get_contents($imageurl);
$base64 = base64_encode($imagedata);
$image = [
	'image' => $base64
];
$imageResult = $this->service->uploadImage($image);

// create a new contract (i.e. a new product offering)
$contract = [
	'expiration_date' => '',
	'metadata_category' => 'physical good',
	'title' => 'Product Title',
	'currency_code' => 'EUR',
	'description' => 'A Description about the product',
	'price' => '9.90',
	'process_time' => '1',
	'nsfw' => 'false',
	'terms_conditions' => '',
	'shipping_origin' => 'GERMANY',
	'ships_to' => 'ALL',
	'est_delivery_domestic' => '2 Business Days',
	'est_delivery_international' => '7-21 Business Days',
	'returns' => '',
	'shipping_currency_code' => 'EUR',
	'shipping_domestic' => 6,
	'shipping_international' => 12,
	'keywords' => 'vinyl',
	'category' => '',
	'condition' => 'New',
	'sku' => '',
	'free_shipping' => 'false',
	'images' => $imageResult['image_hashes'][0],
	'moderators' => 'e85ac56a60d01fa5ad20b3194bfc1c593db17cba',
	'contract_id' => '',
];
$result = $this->service->createContract($contract);

phpcs --standard=cakephp php-openbazaar-api/

bin/phpunit davalb/php-openbazaar-api/tests/