Amazon soap interface using php - php

Hi i am trying to use soap to get results from amazon, and i havent tried this before so i was trying some sample code. The problem is i get an error.
the code is this:
<?php
#Use the NuSOAP php library
//require_once('lib/nusoap.php');
$params->AWSAccessKeyId = AMAZON_API_KEY;
$params->Request->SearchIndex = 'Books';
$params->Request->Keywords = 'php5';
$amazon = new SoapClient('http://webservices.amazon.com/AWSECommerceService /AWSECommerceService.wsdl');
$result = $amazon->itemSearch($params);
echo $result;
?>
and this is the error i get when i run it. thanx for your time
Fatal error: Uncaught SoapFault exception: [aws:Client.MissingParameter] The request must contain the parameter Signature. in C:\wamp\www\amasearch.php:11 Stack trace: #0 [internal function]: SoapClient->__call('itemSearch', Array) #1 C:\wamp\www\amasearch.php(11): SoapClient->itemSearch(Object(stdClass)) #2 {main} thrown in C:\wamp\www\amasearch.php on line 11

Weird. The WSDL doesn't have a signature parameter for any type. BUT, I found this in Amazon dev forums. Recommend you to check it out (also, if you develop using amazon services, keep that resource at hand
https://forums.aws.amazon.com/ann.jspa?annID=483
Looks like security gates for services are now taller and bigger, mate
EDIT: This question link to some example in C#. Maybe it can help you out Amazon (AWS) - The request must contain the parameter Signature
And this is an example in AWS forums with PHP https://forums.aws.amazon.com/message.jspa?messageID=149715

Related

Woocommerce rest API - 'Error: Invalid signature - provided signature does not match

I'm trying to download order details from a woocommerce API for easy display and update purpose.
I tested the entire setup locally with two separate web addresses. One for test woocommerce install [copy from production site] and one for order display webpage.
Everything works fine locally. But when I connect the order display to production. It downloads all orders and display according to my design, But when I try to update an order it throws an exception.
After googling for a while found that this could be caused by timezone differences, checked time on both server and my pc it was spot on.
Anyway I changed
php timezone to correct one on both server and pc php.ini and restarted httpd
changed server linux timezone and rebooted the server.
Still, I get following only in production[hosted in AWS]. In no expert on php, but got some programming knowledge. Anyone who can point me to correct direction?
Fatal error: Uncaught exception
'Automattic\WooCommerce\HttpClient\HttpClientException' with message 'Error:
Invalid signature - provided signature does not match.
[woocommerce_rest_authentication_error]' in
C:\xampp\htdocs\orderdash\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php:348 Stack trace: #0
C:\xampp\htdocs\orderdash\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php(378): Automattic\WooCommerce\HttpClient\HttpClient->lookForErrors(Object(stdClass)) #1
C:\xampp\htdocs\orderdash\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php(414): Automattic\WooCommerce\HttpClient\HttpClient->processResponse() #2
C:\xampp\htdocs\orderdash\vendor\automattic\woocommerce\src\WooCommerce\Client.php(69): Automattic\WooCommerce\HttpClient\HttpClient->request('orders/544', 'PUT', Array) #3
C:\xampp\htdocs\orderdash\index.php(149): Automattic\WooCommerce\Client->put('orders/544', Array) #4 {main} thrown in
C:\xampp\htdocs\orderdash\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php on line 348
Connection
$woocommerce = new Client('http://example.com/',
'ck_321cad474478e1275',
'cs_76f8566e67cd7aa31',
['wp_api' => true, 'version' => 'wc/v1']);
Download orders
$data = ['status' => 'processing'];
$order_details = $woocommerce->get('orders',$data);
update data [use a button submit]
$update_order_id = $_POST['orderid'];
$st = ['status' => 'completed'];
$woocommerce->put('orders/'. $update_order_id, $st);

how to connect with salesforce using php?

I am trying to connect with Salesforce using below lib and getting below issue and unable to find how
to enable the API as per Error.
https://github.com/developerforce/Force.com-Toolkit-for-PHP
Code:-
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once ('soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
$mylogin = $mySforceConnection->login("xyz#gmail.com", "pass#xa9Ur9xMD6qqdRhdmLBuiRev");
var_dump($mylogin);die;
?>
Fatal error: Uncaught SoapFault exception: [sf:API_DISABLED_FOR_ORG] API_DISABLED_FOR_ORG:
API is not enabled for this Organization or Partner in
/var/www/mssdev/force/soapclient/SforceBaseClient.php:168 Stack trace:
#0 /var/www/mssdev/force/soapclient/SforceBaseClient.php(168): SoapClient->__call('login', Array)
#1 /var/www/mssdev/force/soapclient/SforceBaseClient.php(168): SforceSoapClient->login(Array)
#2 /var/www/mssdev/force/index.php(11): SforceBaseClient->login('xyz#gm...', 'fas#xa9Ur9...')
#3 {main} thrown in /var/www/mssdev/force/soapclient/SforceBaseClient.php on line 168
You are probably using Salesforce Gorup or Professional edition where the API is not available.
Other scenario (if You have other edition tham mentioned above) that the API is not enabled for Your user. However from the error message the most possible is scenario #1.
Use the developer account and the issue has solved.

Couldn't resolve host '1511623453.cloud.vimeo.com'

Alright... I've chased the trail around the internet for this one, and I'm coming up with nothing.
Trying to use the PHP Vimeo API to upload videos. I have upload permission on my app, I've got tokens, and client id and secret stuff all set up, and a small myriad of other things that I've put together to make everything work... and... now I'm getting this and I have no idea what to do with it :P
PHP Fatal error: Uncaught exception 'Vimeo\Exceptions\VimeoRequestException' with message 'Unable to complete request.[Couldn't resolve host '1511623453.cloud.vimeo.com']' in /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php:154 Stack trace:
#0 /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php(396): Vimeo\Vimeo->_request('https://1511623...', Array)
#1 /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php(320): Vimeo\Vimeo->perform_upload('users/test/outp...', Array)
#2 /home/theo/software-dev/vim_test.php(20): Vimeo\Vimeo->upload('users/test/outp...', false)
#3 {main} thrown in /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php on line 154
The upload script is super simple, and I doubt to be the source of the error, though here it is:
1 <?php
2 include("./config/vim.php");
3 require("./classes/vimeo/autoload.php");
4
5 $lib = new \Vimeo\Vimeo($client_id, $client_secret);
6
7 $lib->setToken($token);
8
9 $response = $lib->upload('users/test/output.mp4', false);
Any suggestions or thoughts?
Thanks!
Try and close all the browers on the computer or phone then make sure your api has the lastet version.

aws s3 php: fails to upload directory using UploadSyncBuilder

I am trying to upload a 14MB directory to s3 using aws php sdk. These are following scenarios and their results
Upload from my local system(india) to s3(us-east-1): success
Upload from ec2(ap-southeast-1) to s3(ap-southeast-1): success
Upload from ec2(ap-southeast-1) to s3(us-east-1): FAIL
The following code I have used
require('application/classes/vendor/autoload.php');
use Aws\S3\S3Client;
use Aws\Common\Credentials\Credentials;
use Aws\S3\Sync\UploadSyncBuilder;
use Guzzle\Log\ClosureLogAdapter;
use Guzzle\Plugin\Log\LogPlugin;
$newCredentials = new Credentials("API_KEY", "SECRET_KEY");
$s3 = S3Client::factory();
//$logPlugin = Guzzle\Plugin\Log\LogPlugin::getDebugPlugin();
$stream = fopen('out.log', 'w');
$logPlugin = new LogPlugin(new ClosureLogAdapter(function ($m) use ($stream) {
fwrite($stream, $m . PHP_EOL);
}), "# Request:\n{request}\n\n# Response:\n{response}\n\n# Errors: {curl_code} {curl_error}", true);
$s3->addSubscriber($logPlugin);
$s3->setCredentials($newCredentials);
$s3->setRegion("us-east-1");
UploadSyncBuilder::getInstance()
->setClient($s3)
->setBucket("BUCKET")
->setAcl("public-read")
->uploadFromDirectory("/mnt/1410503562Welcome to Leap!.zip_ext")
->setKeyPrefix("customs3/game10906/1410501964WelcometoLeap.zip_ext")
->setConcurrency(5)
->build()
->transfer();
Exception
PHP Fatal error: Uncaught exception 'Guzzle\Service\Exception\CommandTransferException' with message 'Errors during multi transfer (Guzzle\Http\Exception\RequestException) ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php line 569
Error completing request
#0 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(378): Guzzle\Http\Message\Request->processResponse(Array)
#1 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php(49): Guzzle\Http\Message\Request->setState('complete', Array)
#2 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(286): Guzzle\Http\Message\EntityEnclosingRequest->setState('complete', Array)
#3 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(244): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#4 ./application/classes/vendor/guzzle/guzzle in /vol/selfserve/application/classes/vendor/guzzle/guzzle/src/Guzzle/Service/Exception/CommandTransferException.php on line 25
I have setup log to debug and dig through Guzzle library as well. I found that when it fails, for a request no response comes. When I set concurrency to 1, it succeeds but takes much time. It fails even at concurrency of 2.
If any file fails, whole upload fails leaving it in partial uploaded state. I could not find any way to set options to retry if something fails.
Thanks for help!
After contacting with AWS support I was able to solve this with their help. Issue was in guzzle library. Following is the response from AWS support
This error occurs when cURL fails to rewind a stream and does not
associate an error with a curl handle. We've added checks to account
for this situation and automatically retry. Please ensure that they
are using the latest version of the SDK and version 3.9.2+ of Guzzle.

How to test google market place api with php

I'm trying to use this api http://code.google.com/p/android-market-api/. I would like to get some that from play store. like App name, description, screenshots and download rating(total downloads, week downloads....)
I'm using the php version. I uploaded all the code to my personal server. www.example.com/test/.
Should I configure anything else in addition of local.php, email and password fields? I only did that.
I have this error:
Uncaught exception 'Exception' with message 'HTTP request returned code 400' in /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php:212 Stack trace:
#0 /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php(160): MarketSession->executeRawHttpQuery('??????DQAAAMkAA...')
#1 /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php(147): MarketSession->executeProtobuf(Object(Request))
#2 /homepages/31/d229886149/htdocs/carlos/test/examples/test_categories.php(15): MarketSession->execute(Object(Request_RequestGroup))
#3 {main} thrown in /homepages/31/d229886149/htdocs/carlos/test/Market/MarketSession.php
on line 212
Thank you.
After that I would like to implement it with codeIgniter
try with '0123456789123456' as an ANDROID_DEVICEID
define('GOOGLE_EMAIL','someone#gmail.com');
define('GOOGLE_PASSWD','SomePassword');
define('ANDROID_DEVICEID','0123456789123456');

Categories