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

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);

Related

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.

Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL

I'm using SSRS SDK for PHP
PHP Version 5.4
WebServer: Centos 6.4
MSSQL Server 2008 R2
When I make
$ssrs_report = new SSRSReport(new Credentials(UID, PASWD), SERVICE_URL);
I got the following error
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from 'http://172.16.4.63/ReportServerURL/Pages/ReportViewer.aspx?%2fTestFolder%2ftestClaimHdr&rs:Command=Render/ReportExecution2005.asmx?wsdl' :
Premature end of data in tag html line 1 in /var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php:196
Stack trace: #0 /var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php(196):
SoapClient->SoapClient('http://172.16.4...', Array) #1 /var/www/emilio/SSRS/index.php(12):
SSRSReport->SSRSReport(Object(Credentials), 'http://172.16.4...') #2 {main} thrown in
/var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php on line 196
I'm looking how to fix it and get the report trough the soap(SSRS SDK for PHP).
I tried using file_get_content() and curl and both worked fine, then isn't connection problems, I have
Soap Client enabled
allow_url_fopen is On
this is the line where the sdk call the soap service
$executionServiceUrl="http://172.16.4.63/ReportServerURL?%2fTestFolder%2ftestClaimHdr&rs:Command=Render/ReportExecution2005.asmx?wsdl";
$options = array ( 'login' => 'xxxx\\xxxx', 'password' => 'xxxx', )
$this->_soapHandle_Exe = new SoapClient($executionServiceUrl, $options);
Adding
try {
$this->_soapHandle_Exe = new SoapClient($executionServiceUrl, $options);
} catch (Exception $e) {
var_export(libxml_get_last_error());
}
I get the following array:
LibXMLError::__set_state(array(
'level' => 3,
'code' => 77,
'column' => 43325,
'message' => 'Premature end of data in tag html line 1',
'file' => 'http://172.16.4.63/ReportServerURL?%2fTestFolder%2ftestClaimHdr&rs:Command=Render/ReportExecution2005.asmx?WSDL',
'line' => 1,
)
According to xmlerror from libxml2
level 3 = XML_ERR_FATAL = 3 : A fatal error
code 77 = XML_ERR_TAG_NOT_FINISHED = 77 : 77
I have alredy set the Basic authentication in the SSRS SERVER
Update
As #jwhaley58 said I changed to:
define("SERVICE_URL", "http://172.16.4.63/ReportServerURL");
$ssrs_report = new SSRSReport(new Credentials(UID, PASWD), SERVICE_URL);
$ssrs_report->LoadReport2('testClaimHdr',NULL);
and I get:
Fatal error: Uncaught exception 'SSRSReportException' in
/var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php:590 Stack trace: #0
/var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php(326):
SSRSReport->ThrowReportException(Object(SoapFault)) #1 /var/www/emilio/SSRS/index.php(15):
SSRSReport->LoadReport2('testClaimHdr', NULL) #2 {main} thrown in
/var/www/emilio/app/Libraries/SSRSReport/bin/SSRSReport.php on line 590
Some gochas that I only found through trial and error are some configuration issues, on the server that is running the reporting server service, make sure that in your file rsreportserver.config has been modified to allow for basic authentication. By default, if I'm understanding it correctly, it wants a more trustworthy connection type, but the sdk needs you to allow simple name and passwords to be passed. This means that needs to be added to your authentication methods in the configuration.
so for example,
In
C:\Program Files\Microsoft SQL Server\MSRS11.1\Reporting Services\ReportServer\rsreportserver.config (Different for server and version, but you get the idea.)
<Authentication>
<AuthenticationTypes>
<RSWindowsNTLM/>
<RSWindowsBasic/> ##you need to add this one##
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
</Authentication>
IIRC you will have to restart the service for this to take effect.
Also, if you are attempting to RenderAs, some of the template files used to pop the headers have space in them towards the bottom that will prevent you from rendering as Excel, PDF, ect unless that has been fixed since I worked on it.
I'm looking through the code you provided, I may be reading it wrong, but it looks like you are trying to explicitly define the report you're after in the execution url. If that is in fact what you are doing, I believe the fix would be to only define the report base you are connecting to so for your example the url should be http://172.16.4.63/ReportServer/. After that connection is made, you would use the LoadReport2 function to specify which report you need.
Lastly, Where you have the name of the report, it looks like you have a subdirectory called testfolder? if that is still the case, you would need your report name to be "/TestFolder/testClaimHdr" in the call to LoadReport2.
Hope any of that helps.

Google Translate API Access Error: (403) Access Not Configured

This is my first attempt to use the Google API, so I'm probably missing something ridiculously simple.
My API access has been turned on, I've enabled all the web based settings I could find for this feature, setup the Simple API Access and Client ID for web applications, etc.
I'm using the PHP library Google provide here: http://code.google.com/p/google-api-php-client/
As my code wasn't working, I defaulted to their sample code as getting that working usually solves my problems. I've copied their code below:
require_once '../../src/Google_Client.php';
require_once '../../src/contrib/Google_TranslateService.php';
$client = new Google_Client();
$client->setApplicationName('Translation tool');
// Visit https://code.google.com/apis/console?api=translate to generate your
// client id, client secret, and to register your redirect uri.
$client->setDeveloperKey('XXXXXXXXXXXXXXXX');
$service = new Google_TranslateService($client);
$langs = $service->languages->listLanguages();
print "<h1>Languages</h1><pre>" . print_r($langs, true) . "</pre>";
$translations = $service->translations->listTranslations('Hello', 'hi');
print "<h1>Translations</h1><pre>" . print_r($translations, true) . "</pre>";
I have:
checked the developer key, which is the API key
checked the allowed referers
Set the referers to include .DOMAIN.com/
Set the referers to include the IP address
Tried including the OAuth2 client id, secret, etc
None of these have worked. The error I'm getting in full is as follows:
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/language/translate/v2/languages?key=XXXXXXXXXXXXXXXX: (403) Access Not Configured' in /home/google-api-php-client/src/io/Google_REST.php:66 Stack trace: #0 /home/google-api-php-client/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 /home/google-api-php-client/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 /home/google-api-php-client/src/contrib/Google_TranslateService.php(39): Google_ServiceResource->__call('list', Array) #3 /home/google-api-php-client/examples/translate/simple.php(13): Google_LanguagesServiceResource->listLanguages() #4 {main} thrown in /home/google-api-php-client/src/io/Google_REST.php on line 66
I'm loosing the will to code with something that should be much more straight forward. Any advice to what might be the problem?
That 403 error is almost certainly related to the Simple API Key. If for example it was a usage restriction the message would say that so....
Double check and make sure you are using the Simple API key listed for server access and have it set to any IP. Specific IP should work but it may depend on how your server is set up.
You may even want to generate a new key just to make sure the one you have is valid. Specific IP would be best in the long run.
Just did the same thing working with the Custom Search API, had the browser key entered and it caused a big dent in the wall as I banged my head into it. . You Shouldn't need any of the OAuth settings just to get the basics working.
i had the same problem but with the analytics api. In my case i listed the ip of the server in the allowed ip addresses.
So when i removed all ip addresses from the google api's console allowed ip addresses then it started working.

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');

Amazon soap interface using 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

Categories