I need to send POST values to server url, and I'm using this code:
$ogone_ua = new LWP::UserAgent;
$ogone_response = $ogone_ua->post("http://server.url/", {
'ACCEPTURL' => 'http://server.url2',
'AMOUNT' => '1000',
'CURRENCY' => 'USD',
'LANGUAGE' => 'en_US',
'ORDERID' => '20130105220939',
'PSPID' => 'vukasin',
'SHASIGN' => '6AEE128943C7C896A6449FF7C2CE702222995B7F'
} );
but server receives:
POST / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Host: athlon.herrpan.com:2389
User-Agent: SSL-AirKiosk/1.0
Content-Length: 206
Content-Type: application/x-www-form-urlencoded
LANGUAGE=en_US&ACCEPTURL=http%3A%2F%2Fserver.url2&SHASIGN=6AEE128943C7C896A6449FF7C2CE702222995B7F&CURRENCY=USD&AMOUNT=1000&PSPID=vukasin&ORDERID=20130105220939
Why it is not in order? The bank API needs POST values to be sorted, just like in code.
Hashes don't have an inherent order, so the order is lost before ->post is even called. However, POST (to which ->post passes its args) also accepts an array reference.
->post("http://server.url/", [
ACCEPTURL => 'http://server.url2',
AMOUNT => '1000',
CURRENCY => 'USD',
LANGUAGE => 'en_US',
ORDERID => '20130105220939',
PSPID => 'vukasin',
SHASIGN => '6AEE128943C7C896A6449FF7C2CE702222995B7F',
]);
Related
I'm trying to make a POST request with ZF3 Http Client but it comes in as a GET request all the time. I checked the manuals on the zend framework website but I can't find what I'm doing wrong. Probably it will be something small.
My simple script from the client side is:
$request = new Client();
$request->setUri('http://keuringapp.localhost/inspections/pdf/66');
$request->setMethod(Request::METHOD_POST);
$response = $request->send();
die($response->getBody());
on the server side I have this:
$test = $this->getRequest();
print_r($test);exit();
``
and it give met this result:
Zend\Http\PhpEnvironment\Request Object
(
[baseUrl:protected] =>
[basePath:protected] =>
[requestUri:protected] => /nl/inspections/pdf/66
[serverParams:protected] => Zend\Stdlib\Parameters Object
(
[storage:ArrayObject:private] => Array
(
[REDIRECT_APP_ENV] => development
[REDIRECT_STATUS] => 200
[APP_ENV] => development
[HTTP_HOST] => keuringapp.localhost
[HTTP_CONNECTION] => close
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Zend\Http\Client
[PATH] => /usr/bin:/bin:/usr/sbin:/sbin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => keuringapp.localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] => 80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] => /Applications/MAMP/htdocs/keuringapp/public
[SERVER_ADMIN] => you#example.com
[SCRIPT_FILENAME] => /Applications/MAMP/htdocs/keuringapp/public/index.php
[REMOTE_PORT] => 55447
[REDIRECT_URL] => /nl/inspections/pdf/66
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /nl/inspections/pdf/66
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[REQUEST_TIME_FLOAT] => 1562241261.33
[REQUEST_TIME] => 1562241261
[argv] => Array
(
)
[argc] => 0
)
)
This question can be closed. It was a problem due to a language setting in the url
I have some problems with the Account Linking for Google Actions:
I have implemented the OAuth2 steps described in the documentation by Google. I have implemented my OAuth2 server and tested it via Postman and am able to get an access token as expected.
If I try to authenticate from the Google Home app by adding the service to my account, I get taken to my authorization form, the authorization works fine and responds with an authorization code to Google's redirect URI as it is supposed to do. However Googles return URI says 'Account linking failed' and then I get a message in the Google Home app : 'Can't update the settings. Check your connection'.
Another strange thing that I've see from my logging of my Token URL script: I can see an incoming GET request from Google to my Token URL instead of a POST request with the required data as mentioned in the Google documentation. So even though the message 'Account linking failed' appears, it seems that Google is calling my token URL, but with a GET instead of a POST.
These are the logs of the requests to the token URL:
REQUEST FROM POSTMAN (testing software) > OK
__SERVER
Array
(
[USER] => www-data
[HOME] => /var/www
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT] => */*
[HTTP_USER_AGENT] => PostmanRuntime/7.6.1
[HTTP_POSTMAN_TOKEN] => f85664e2-7d38-4511-9519-cddda3feec06
[HTTP_CACHE_CONTROL] => no-cache
[HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
[HTTP_CONTENT_LENGTH] => 145
[HTTP_CONNECTION] => close
[HTTP_HOST] => 127.0.0.1
[REDIRECT_STATUS] => 200
[SERVER_NAME] => _
[SERVER_PORT] => 80
[SERVER_ADDR] => 127.0.0.1
[REMOTE_PORT] => 38622
[REMOTE_ADDR] => 127.0.0.1
[SERVER_SOFTWARE] => nginx/1.12.2
[GATEWAY_INTERFACE] => CGI/1.1
[REQUEST_SCHEME] => http
[SERVER_PROTOCOL] => HTTP/1.0
[DOCUMENT_ROOT] => [******]
[DOCUMENT_URI] => /google/token/index.php
[REQUEST_URI] => /google/token/
[SCRIPT_NAME] => /google/token/index.php
[CONTENT_LENGTH] => 145
[CONTENT_TYPE] => application/x-www-form-urlencoded
[REQUEST_METHOD] => POST
[QUERY_STRING] =>
[SCRIPT_FILENAME] => [******]
[FCGI_ROLE] => RESPONDER
[PHP_SELF] => /google/token/index.php
[REQUEST_TIME_FLOAT] => 1553765980.9273
[REQUEST_TIME] => 1553765980
)
__POST
Array
(
[client_id] => [******]
[client_secret] => [******]
[grant_type] => authorization_code
[code] => [******]
)
REQUEST RECEIVED WHEN TESTING WITH GOOGLE HOME APP on smartphone > NOT OK
__SERVER
Array
(
[USER] => www-data
[HOME] => /var/www
[HTTP_ACCEPT_ENCODING] => gzip,deflate,br
[HTTP_USER_AGENT] => OpenAuth
[HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
[HTTP_CONNECTION] => close
[HTTP_HOST] => 127.0.0.1
[REDIRECT_STATUS] => 200
[SERVER_NAME] => _
[SERVER_PORT] => 80
[SERVER_ADDR] => 127.0.0.1
[REMOTE_PORT] => 46184
[REMOTE_ADDR] => 127.0.0.1
[SERVER_SOFTWARE] => nginx/1.12.2
[GATEWAY_INTERFACE] => CGI/1.1
[REQUEST_SCHEME] => http
[SERVER_PROTOCOL] => HTTP/1.0
[DOCUMENT_ROOT] => [******]
[DOCUMENT_URI] => /google/token/index.php
[REQUEST_URI] => /google/token/
[SCRIPT_NAME] => /google/token/index.php
[CONTENT_LENGTH] =>
[CONTENT_TYPE] => application/x-www-form-urlencoded
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[SCRIPT_FILENAME] => [******]
[FCGI_ROLE] => RESPONDER
[PHP_SELF] => /google/token/index.php
[REQUEST_TIME_FLOAT] => 1553767309.7797
[REQUEST_TIME] => 1553767309
)
__REQUEST
Array
(
)
__POST
Array
(
)
__GET
Array
(
)
-------------------------
__ANSWER
400: invalid grant
Configuration in Actions Console
Problem seemed to be caused by the redirect of / to /index.php without the POST values.
Fixed it by changing my URLs in the Actions Console to /index.php and now the linking works fine.
I am trying to warm up my controller so that the service gets hot during each deployment.
In order to do this i have written a perl script as below:
#!perl
use strict;
use warnings;
use WWW::Mechanize;
use HTTP::Request;
my $ua = WWW::Mechanize->new();
my $r = HTTP::Request->new(
'GET' =>
'http://gaurav_setia.microsoft.com:8080/b2h/homepage?_encoding=UTF8&opf_redir=1&portalDebug=1',
[
'Connection' => 'Keep-Alive',
'Via' => 'HTTP/1.1 ShoppingSchedule',
'Accept' =>
'text/x-html-parts,text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Charset' => 'UTF-8',
'Accept-Encoding' => 'identity',
'Accept-Language' => 'en-US',
'Host' => 'gaurav_setia.microsoft.com',
'User-Agent' =>
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36',
'Cookie' =>
'Original-X-Forwarded-For' => '10.45.103.166',
'X-MS-Internal-Ip-Class' => 'rfc1918',
'X-MS-Internal-Via' =>
'1.1 us-beta-opf-1a-1-67440dc2.us-east-1.ms.com (OPF)',
'X-MS-Urlspace' => 'NoPageType',
'X-MS-Portal-Customer-Id' => 'AMY4OD2PMM9T31',
'X-MS-Portal-Default-Merchant-Id' => 'BTLPDKIKX0DE41',
'X-MS-Portal-Device-Attr' => 'desktop',
'X-MS-Portal-Language' => 'en_US',
'X-MS-Portal-Marketplace-Id' => 'ATVPDKIKX0DER',
'X-MS-Portal-Page-Type' => 'AQGate',
'X-MS-Portal-Request-Attr' => 'internal, http, portal-debug',
'X-MS-Portal-Session-Id' => '1M0-493PO66-0596753',
'X-MS-Portal-Ubid' => '1P2-465OP632-8831161',
'X-MS-Portal-User-Attr' => 'business',
'X-MS-Rid' => 'G308MPK95BWTA69EY2MW',
'X-Forwarded-For' => '10.45.101.126',
'X-Forwarded-Host' => 'development.ms.com',
'X-Forwarded-Server' =>
'development.ms.com, b-hp-shpomnpng-na-2b-02af3555.us-west-2.amazon.com',
'X-Original-Args' => 'portalDebug=1',
'X-Original-Method' => 'GET',
'X-Original-Scheme' => 'http',
'X-Original-Uri' => '/',
],
);
my $res = $ua->request( $r, );
if ( $res->is_success() )
{
print $response->is_success();
}
print $response->status_line;
This script should run after each deployment.
But in the catalina.out logs i am getting the following error:
Dec 13, 2018 9:08:11 AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:235)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1055)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
I am unable to find the fix!
Many answers say that this is due to https/http issue, but i am making a http call here itself!
In amongst your pile of headers, you have this:
'User-Agent' =>
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36',
'Cookie' =>
'Original-X-Forwarded-For' => '10.45.103.166',
Notice that there's no value for the Cookie header. That means all of the headers after that will be wrong (the names and values will be muddled up).
Either remove the Cookie line completely or set its value to undef.
'Cookie' => undef,
(Removing it is probably best)
I have spent couple hours trying to get the value of 'Auth-Token' out of REST api response header, I just don't understand the meaning of bless({ key=> value })
is this a hashref inside an array? How can I loop through it.
$VAR1 = bless( {
'access-control-allow-credentials' => 'true',
'connection' => 'keep-alive',
'x-powered-by' => 'restheart.org',
'client-response-num' => 1,
'access-control-allow-origin' => '*',
'date' => 'Thu, 05 May 2016 22:54:44 GMT',
'client-peer' => '172.18.18.122:8080',
'content-length' => '469',
'access-control-expose-headers' => 'Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By',
'::std_case' => {
'access-control-allow-credentials' => 'Access-Control-Allow-Credentials',
'x-powered-by' => 'X-Powered-By',
'client-response-num' => 'Client-Response-Num',
'access-control-allow-origin' => 'Access-Control-Allow-Origin',
'client-peer' => 'Client-Peer',
'access-control-expose-headers' => 'Access-Control-Expose-Headers',
'client-date' => 'Client-Date',
'auth-token-valid-until' => 'Auth-Token-Valid-Until',
'auth-token-location' => 'Auth-Token-Location',
'auth-token' => 'Auth-Token'
},
'client-date' => 'Thu, 05 May 2016 22:55:00 GMT',
'content-type' => 'application/hal+json',
'auth-token-valid-until' => '2016-05-05T23:09:44.471Z',
'auth-token-location' => '/_authtokens/test',
'auth-token' => 'fbbb0215-cedd-4a10-9f89-93fdf1e84fdc'
}, 'HTTP::Headers' );
That's a hash that's been blessed into an HTTP::Headers object. You can access what you need by using its API:
my $token = $VAR1->header('auth-token');
I wouldn't recommend accessing it via the hash directly (breaking encapsulation), in case the internals of HTTP::Headers ever changes.
Its common in perl5 to use a hash for objects. In this case, you have a 'HTTP::Headers' object in $VAR1. Under the hood, the object is a blessed HashRef, so what your are seeing are the ordinary "guts" of a hash. To the left of the "fat commas" are the keys and to the right are the values.
So, your question boils down to - given a hashref in a variable, how do I get the value for key 'x'? Now, here is how you do that - but DONT do it.
print $VAR1->{ auth-token };
The reason why I say "dont do it" is that you're breaking a fundamental principle of OO programming called encapsulation. The details of the object are not supposed to be any of your business. Instead use the methods provided by the class (ie, provided by the module HTTP::Headers)
Reading the HTTP::Heders doco, you can get the header for 'auth token' like so;
print $VAR1->header( 'auth-token' )
This is what you need to do.
I'm trying to create recurring payment profile using CreateRecurringPaymentsProfile method of Paypal API version 54.0 56.0 in Sandbox mode.
Unfortunately I'm getting 10002 error "You do not have permissions to make this API call".
I've rechecked API credentials for few times and it looks correct. Also other methods of API (ex. DoDirectPayment) works perfectly.
Does anybody faced such a problem? What a solution?
Thank you very much I need your help.
UPD:
The request is performed by Zend_Http_Client. Sending get array like:
array (
'USER' => 'user_1324103739_biz_api1.domain.com',
'PWD' => 'DCM6SLXFXLW99RRR',
'SIGNATURE' => 'signature',
'VERSION' => '56.0',
'METHOD' => 'CreateRecurringPaymentsProfile',
'TOKEN' => 'EC-12C13621A5208361W',
'IPADDRESS' => '127.0.0.1',
'USER_AGENT' => 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7',
'AMT' => 100,
'SUBJECT' => 'Silver plan monthly payment',
'CURRENCYCODE' => 'USD',
'COUNTRYCODE' => 'US',
'EMAIL' => 'user#email.com',
'PROFILESTARTDATE' => '2012-19-01CST3:48:2418',
'BILLINGPERIOD' => 'Month',
'BILLINGFREQUENCY' => 1)
The request example:
GET /nvp?USER=user_1324103739_biz_api1.domain.com&PWD=DCM6SLXFXLW99RRR&SIGNATURE=signature&VERSION=56.0&METHOD=CreateRecurringPaymentsProfile&TOKEN=EC-12C13621A5208361W&IPADDRESS=127.0.0.1&USER_AGENT=Mozilla%2F5.0+%28X11%3B+Linux+i686%29+AppleWebKit%2F535.7+%28KHTML%2C+like+Gecko%29+Chrome%2F16.0.912.63+Safari%2F535.7&AMT=100&SUBJECT=Silver+plan+monthly+payment&CURRENCYCODE=USD&COUNTRYCODE=US&EMAIL=user%40email.com&PROFILESTARTDATE=2012-19-01CST3%3A48%3A2418&BILLINGPERIOD=Month&BILLINGFREQUENCY=1 HTTP/1.1
Host: api-3t.sandbox.paypal.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Response example:
TIMESTAMP=2011%2d12%2d19T09%3a55%3a14Z&CORRELATIONID=3fcaa599c0ad0&ACK=Failure&VERSION=56%2e0&BUILD=2230381&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Authentication%2fAuthorization%20Failed&L_LONGMESSAGE0=You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call&L_SEVERITYCODE0=Error
SUBJECT is causing this. SUBJECT is meant for third-party API authorization where the value of SUBJECT is the email address / secure merchant ID of a third party which authorized you to call the API on their behalf, not as a descriptive text. For that you'll want to use 'DESC'.
I would also suggest removing:
IPADDRESS (not part of CreateRecurringPaymentsProfile API)
COUNTRYCODE (not part of CreateRecurringPaymentsProfile API)