require __DIR__ . '/woo-api/vendor/autoload.php';
use Automattic\WooCommerce\HttpClient\HttpClientException;
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://mysite.info/',
$ck,
$cs,
[
'wp_api' => true, 'version' => 'wc/v3',
]
);
$data = ['status' => 'processing'];
$woocommerce->put('orders/1242', $data); // Not Working
$woocommerce->get('products')); // Working
$woocommerce->get('products')); // Working
$woocommerce->get('customers',array('per_page' => 100, 'page' => $page)));// Working
i'm trying to update order status .. but this is not working ! :(
is there anything wrong with this code ?
$woocommerce->get('products')); => working
$woocommerce->get('customers',array('per_page'=>100,'page' => $page)) => working
With the same code i can get the customers data, product data...
but when i try to Update an order
its giving me "HTTP ERROR 500"
And the error log is mentioned Bellow Error Log :: –
/home2/wpqwerty/public_html/wooapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(422): Automattic\WooCommerce\HttpClient\HttpClient->processResponse()
#1 /home2/wpqwerty/public_html/woo-api/vendor/automattic/woocommerce/src/WooCommerce/Client.php(69): Automattic\WooCommerce\HttpClient\HttpClient->request('orders/1242', 'PUT', Array)
#2 /home2/wpqwerty/public_html/test_api.php(16): Automattic\WooCommerce\Client->put('orders/1242', Array) #3 {main} thrown in /home2/wpqwerty/public_html/wooapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 378
Related
require __DIR__ . '/woo-api/vendor/autoload.php';
use Automattic\WooCommerce\HttpClient\HttpClientException;
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://mysite.info/',
$ck,
$cs,
[
'wp_api' => true, 'version' => 'wc/v3',
]
);
$data = ['status' => 'processing'];
$woocommerce->put('orders/1242', $data); // Not Working
$woocommerce->get('products')); // Working
$woocommerce->get('products')); // Working
$woocommerce->get('customers',array('per_page' => 100, 'page' => $page)));// Working
I'm trying to update order status .. but this is not working ! :(
is there anything wrong with this code ?
$woocommerce->get('products')); => working
$woocommerce->get('customers',array('per_page'=>100,'page' => $page)) => working
With the same code I can get the customers data, product data...
but when I try to Update an order
its giving me "HTTP ERROR 500"
And the error log is mentioned Bellow Error Log :
/home2/wpqwerty/public_html/wooapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(422):
Automattic\WooCommerce\HttpClient\HttpClient->processResponse()
#1 /home2/wpqwerty/public_html/woo-api/vendor/automattic/woocommerce/src/WooCommerce/Client.php(69):
Automattic\WooCommerce\HttpClient\HttpClient->request('orders/1242',
'PUT', Array)
#2 /home2/wpqwerty/public_html/test_api.php(16): Automattic\WooCommerce\Client->put('orders/1242', Array) #3 {main}
thrown in
/home2/wpqwerty/public_html/wooapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
on line 378
Hi I am trying to use coinbase api in php.api implementation working fine, I can check balance, creat new address all this are working fine.But facing problem on request bitcoin. I am following coinbase official api librery , accroding documention on mentioned link request fund usage code is
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;
$transaction = Transaction::request([
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($transaction);
And I used exactly what they said, but I am getting error, bellow is my code
<?php
require_once('vendor/autoload.php');
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;
$apiKey='xxxxxxx';
$apiSecret='xxxxxxx';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$transaction = Transaction::request([
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($transaction);
echo json_encode($client->decodeLastResponse());
?>
And error is
Fatal error: Uncaught TypeError: Argument 1 passed to
Coinbase\Wallet\Client::createAccountTransaction() must be an instance
of Coinbase\Wallet\Resource\Account, instance of
Coinbase\Wallet\Resource\Transaction given, called in
/file_path/file.php on line 19 and defined in
/library_path /vendor/coinbase/coinbase/src/Client.php:359 Stack
trace: #0 /file_path/file.php(19):
Coinbase\Wallet\Client->createAccountTransaction(Object(Coinbase\Wallet\Resource\Transaction))
1 {main} thrown in /library_path /vendor/coinbase/coinbase/src/Client.php on line 359
update:
I tried by adding specific account parameter
$account=$client->getPrimaryAccount();
$transaction = Transaction::request([
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($account,$transaction);
And then I got error exception To peremeter missing so I added to parameter
Transaction::request([
'to'=>'test#mail.com',
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
And now error is
Fatal error: Uncaught TypeError: Argument 1 passed to
Coinbase\Wallet\Resource\Transaction::setTo() must be an instance of
Coinbase\Wallet\Resource\Resource, string given, called in
/home/exhakduz/api/vendor/coinbase/coinbase/src/Resource/Resource.php
on line 70 and defined in /library_path
/vendor/coinbase/coinbase/src/Resource/Transaction.php:199 Stack
trace: #0 /library_path
/vendor/coinbase/coinbase/src/Resource/Resource.php(70):
Coinbase\Wallet\Resource\Transaction->setTo('test#mail.com') #1
/library_path /vendor/coinbase/coinbase/src/Resource/Resource.php(25):
Coinbase\Wallet\Resource\Resource->updateAttributes(Array) #2
/library_path
/vendor/coinbase/coinbase/src/Resource/Transaction.php(119):
Coinbase\Wallet\Resource\Resource->__construct('transaction', Array)
3 /library_path /vendor/coinbase/coinbase/src/Resource/Transaction.php(114):
Coinbase\Wallet\Resource\Transaction->__construct('request', Array) #4
/library_path /receive.php(20):
Coinbase\Wallet\Resource\Transaction::request(Ar in /library_path
/vendor/coinbase/coinbase/src/Resource/Transaction.php on line 199
Your call should also reference $account:
$account = $client->getPrimaryAccount();
$transaction = Transaction::request([
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($account, $transaction);
Try
$client->createAccountTransaction($account, $transaction);
Transaction::request([
'toEmail'=>'test#mail.com',
'amount' => new Money(8, CurrencyCode::USD),
'description' => 'Burrito'
]);
$client->createAccountTransaction($account, $transaction);
Creating a order from php rest api of woo-commerce version: wc/v3 and getting error
other apis are working fine tried with v2 still getting the same error
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$wc = new Client(
'https://example.com/',
'client key',
'client secret',
[
'wp_api' => true,
'version' => 'wc/v3',
]
);
$data = [
'payment_method' => 'cod',
....
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => 10
]
]
];
print_r($wc->post('orders', $data));
Getting this error, if i remove shipping lines working fine and creating the order
[07-May-2019 06:39:45 UTC] PHP Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: Error: Invalid parameter(s): shipping_lines [rest_invalid_param] in /home/gathhnaw/public_html/mapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:350
Stack trace:
#0 /home/gathhnaw/public_html/mapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(386): Automattic\WooCommerce\HttpClient\HttpClient->lookForErrors(Object(stdClass))
#1 /home/gathhnaw/public_html/mapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(422): Automattic\WooCommerce\HttpClient\HttpClient->processResponse()
#2 /home/gathhnaw/public_html/mapi/vendor/automattic/woocommerce/src/WooCommerce/Client.php(56): Automattic\WooCommerce\HttpClient\HttpClient->request('orders', 'POST', Array)
#3 /home/gathhnaw/public_html/mapi/create_order.php(46): Automattic\WooCommerce\Client->post('orders', Array)
#4 {main}
thrown in /home/gathhnaw/public_html/mapi/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 350
There seems to be a typo or documentation error on woo api. Just surround the total value between single quotes and run it
https://www.infocaptor.com/dashboard/woocommerce-rest-api-php-example-error-creating-order
When we are calling Uber Products API, its working perfect but when we call Ride Reminder API, we getting following 404 errors:
PHP Fatal error: Uncaught exception GuzzleHttp\Exception\ClientException
with message
Client error: POST https://sandbox-api.uber.com/v1.2/reminders
resulted in a 404 Not Found response:
404 page not found in
/var/www/html/uber/uber/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/www/html/uber/uber/vendor/guzzlehttp/guzzle/src/Middleware.php(65):
GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request),
Object(GuzzleHttp\Psr7\Response))
#1 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(203):
GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(156):
GuzzleHttp\Promise\Promise::callHandler(1,
Object(GuzzleHttp\Psr7\Response), Array)
#3 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/TaskQueue.php(47):
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /var/www/html/uber/uber/vendor/guzzlehttp/promises/src/Promise.php(246):
Guzzle in
/var/www/html/uber/uber/vendor/stevenmaguire/uber-php/src/Client.php
on line 173
We are using following sample code to work out, let me know what could be issue.
<?php
include "vendor/autoload.php";
$client = new Stevenmaguire\Uber\Client(array(
'access_token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'server_token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'use_sandbox' => true, // optional, default false
'version' => 'v1.2', // optional, default 'v1.2'
'locale' => 'en_US', // optional, default 'en_US'
));
$products = $client->getProducts(array(
'latitude' => '41.85582993',
'longitude' => '-87.62730337'
));
var_dump($products);
$attributes = array(
'reminder_time' => '1429294463',
'phone_number' => '555-555-5555',
'event' => array(
'time' => '1515750429',
'name' => 'John with friends',
'location' => 'Dolores Park',
'latitude' => '37.759773',
'longitude' => '-122.427063',
'product_id' => "737d4e43-9e12-4a81-add3-acb101bab4c7",
),
);
$reminder = $client->createReminder($attributes);
var_dump($reminder);
Please help us to fix this.
Documentation is removed for ride reminders from http://developer.uber.com and they are not currently supported.
I working on a web application and since a lot of read and write action happening in the amazon dynamodb table am facing a provisionthroughput error. Thinking of using a Update table I used below code but facing error. This error is not mentioned in error handling chart of dynamobb.
<?php
use Aws\DynamoDb\DynamoDbClient;
$dynamoDB = DynamoDbClient::factory(array(
'key' => '',
'secret' => '',
'region' => Region::US_WEST_1
));
####################################################################
# Updating the table
// $dynamodb = new AmazonDynamoDB();
echo PHP_EOL . PHP_EOL;
echo "# Updating the \"${dynamo_db_table}\" table..." . PHP_EOL;
$up = $dynamoDB->Update_table(array(
'TableName' => $dynamo_db_table,
'ProvisionedThroughput' => array(
'ReadCapacityUnits' => 39,
'WriteCapacityUnits' => 37
)
));
$table_status = $dynamoDB->describe_table(array(
'TableName' => $dynamo_db_table
));
// Check for success...
if ($table_status->isOK())
{
print_r($table_status->body->Table->ProvisionedThroughput->to_array()->getArrayCopy());
}
else
{
print_r($table_status);
}
$count = 0;
do {
sleep(5);
$count += 5;
$response = $dynamoDB->describe_table(array(
'TableName' => $table_name
));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');
echo "The table \"${table_name}\" has been updated (slept ${count} seconds)." . PHP_EOL;
?>
I am facing below error:
# Updating the "tablename" table...
Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching Update_table' in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:117 Stack trace: #0 /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php(94): Guzzle\Service\Client->getCommand('Update_table', Array) #1 /home/phretscl/public_html/RETS/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php(103): Guzzle\Service\Client->__call('Update_table', Array) #2 /home/phretscl/public_html/RETS/file.php(97): Aws\Common\Client\AbstractClient->__call('Update_table', Array) #3 /home/phretscl/public_html/RETS/file.php(97): Aws\DynamoDb\DynamoDbClient->Update_table(Array) #4 {main} thrown in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 117
The code you are using is not correct. From the error message, I can tell you are using version 2.x of the AWS SDK for PHP, but the code you using from ############ line down looks like it is meant for version 1.x of the AWS SDK for PHP. The error is being thrown, because you are not calling the DynamoDbClient::updateTable() method correctly.
You should checkout the AWS SDK for PHP User Guide, particularly the page about DynamoDB, which has a code sample for UpdateTable.
EDIT w/ regards to the comments: If this is a long running process, you should use the Aws\Common\Aws way of instantiating the client, since it retains and reuses the client objects it creates. Replace you DynamoDbClient::factory(...) code with this:
use Aws\Common\Aws;
$aws = Aws::factory(array(
'key' => '...',
'secret' => '...',
'region' => Region::US_WEST_1
));
$dynamoDB = $aws->get('dynamodb');
You should provide the credentials like this
Also, the region should be like this 'region'=>'us-east-1'
$DDBClient = DynamoDbClient::factory([
'region'=>'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => 'XXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXX'
]
,'scheme' => 'http' // Use this if you don't have HTTPS
//, 'debug' => true
]);