With email parameter , which ends with dot com, can't get Result from Restful Web Service by using Perl LWP - perl

I want to use perl with Module LWP to get the XML info from Restful Webservice.
Here is the Code:
my $ua = LWP::UserAgent->new;
$ua->proxy(['http','https'],'http://proxy:3128');
$ua->default_header('Accept-Charset'=>'utf-8');
$ua->default_header('Accept'=>'application/*********; version=1');
my $url= 'https://user:password#mailbox.********.net/mailboxes/?emailaddress=name#domain.net';
print Dumper($ua->get($url));
It works always good for all the email address like .eu, .org or .net, except for the email address ends with .com. (For example: name#domail.com)
The error message is:
The following error was encountered while trying to retrieve the URL:
https://user#mailbox.******.net/mailboxes/?
Access Denied.
Access control configuration prevents your request from being allowed at this time.
Please contact your service provider if you feel this is incorrect.
Your cache administrator is *****#**.**
The corresponded Response HEAD:
'_headers' => bless( {
'connection' => 'close',
'client-response-num' => 1,
'date' => 'Wed, 19 Nov 2014 15:53:45 GMT',
'x-squid-error' => 'ERR_ACCESS_DENIED 0',
'client-peer' => '****:3128',
'content-length' => '3502',
'client-date' => 'Wed, 19 Nov 2014 15:53:45 GMT',
'content-type' => 'text/html',
'mime-version' => '1.0',
'title' => 'ERROR: The requested URL could not be retrieved',
'server' => 'squid/3.1.12',
'x-cache' => 'MISS from proxy',
'x-cache-lookup' => 'NONE from proxy:3128'
}, 'HTTP::Headers' ),
I have tested with SoapUI and curl, they didn't meet this problem. That means .com works also with SoapUI and cuil. Only in perl with LWP, it gets problem.
Anyway when I added a dummy parameter like
https://**/mailboxes/?emailaddress=name#domain.com&foo=bar at the end of the link, it works.
I have no idea, if it's a bug in LWP or maybe some incompatible issue between LWP and Proxy Setting.

Access Denied.
Access control configuration prevents your request from being allowed at this time.
Please contact your service provider if you feel this is incorrect.
...
'x-squid-error' => 'ERR_ACCESS_DENIED 0',
There is an ACL in the proxy you use which denies your request.
If you have access to the proxy configuration check there, otherwise contact you cache administrator with your problem.

Related

Uber API issue : Getting error while using this code. SSL certificate self signed certificate in certificate chain

I am new to Uber API, I just started exploring the Uber API's.
I have downloaded the complete Uber API repository from https://github.com/stevenmaguire/uber-php/issues/17
I have downloaded the complete repository using the composer. It shows that all dependencies were downloaded successfully. but when I am using the API, I am getting this error
Blockquote"SSL certificate problem: self signed certificate in certificate chain"
Please help me in this, I have raised this issue 8 days back on the Github no one is replied.
Here is my code
Thanks in Advance.
Rakesh
Here is my code`
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Stevenmaguire\Uber\Client(array(
'access_token' => '********',
'server_token' => '********',
'use_sandbox' => false, // 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);
?>
`

PayPal Sandbox 500 Proxy Error- PayPal Adaptive

We are aware that PayPal rolling out upgrades to make use of SSL/TLS SHA256 for security purposes. Today i met with strange issue on PayPal Sandbox mode for my PayPal Adaptive Application even though my site follows HTTPS. To add further, same application works fine in Production(not sandbox).Please enlighten me, was this an issue in Application or Rollout issues? same issue reported in PayPal community but no response https://www.paypal-community.com/t5/About-Payments/Adaptive-payment-api-is-sending-Proxy-error/m-p/1091510
The proxy server could not handle the request AdaptivePayments/Pay Reason: Error during SSL
Handshake with remote server
07-27-2016 # 13:43:35 - Error in generate payment key: Array
[headers] => Array
[date] => Wed, 27 Jul 2016 13:43:35 GMT
[server] => Apache
[connection] => close
[http_x_pp_az_locator] => sandbox.slc
[paypal-debug-id] => 8913861a40cd4
[set-cookie] => Array
(
[0] => X-PP-SILOVER=name%3DSANDBOX3.APIT.1%26silo_version%3D1880%26app%3Dadaptivepaymentspartaweb_api3t%26TIME%3D2277152855%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Wed, 27 Jul 2016 14:13:35 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
[1] => X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
[response] => Array
(
[code] => 500
[message] => Proxy Error
)
[cookies] => Array
(
[0] => WP_Http_Cookie Object
(
[name] => X-PP-SILOVER
[value] => name=SANDBOX3.APIT.1&silo_version=1880&app=adaptivepaymentspartaweb_api3t&TIME=2277152855&HTTP_X_PP_AZ_LOCATOR=sandbox.slc
[expires] => 1469628815
[path] => /
[domain] => .paypal.com
[secure] =>
[httponly] =>
)
[1] => WP_Http_Cookie Object
(
[name] => X-PP-SILOVER
[value] =>
[expires] => 1
[path] => /AdaptivePayments/
[domain] => svcs.sandbox.paypal.com
Edit July 28th, 9:50am EDT: It appears the teams were able to track down what they believe to be the issue overnight, and released a code fix. Can you please verify that the problem has been fixed? I'll report back if that's not the case. Thanks.
We've had a few reports about failed requests on sandbox. I'm working with the sandbox and support teams internally in PayPal to figure out what's going on. Right now it looks like they're seeing the error responses and have teams on it to diagnose the problem. Just to note, this does look like it's restricted to sandbox and not any of the production servers. I'll post back when I hear more.

Perl LWP get blocked by server 404 not found

I am using LWP::UserAgent to download an csv in unix server
my $ua1 = LWP::UserAgent->new();
my $res = $ua1->get($equity_history_url, #netscape_like_headers);
The server keeps giving me an error with code 404 (not found)
Despite that I can download this file from the browser ->
http://www.nseindia.com/content/equities/scripvol/datafiles/18-08-2013-TO-17-08-2015ADANIPOWERALLN.csv
and the code works with other pages
I think the issue is one of the below
The site is looking for a cookie.
The site is decoding the agent string.
The site is making a decision based on some other part of the
HTTP request header.
I tried passing a header similar to my browser which I captured using wireshark
my #netscape_like_headers = (
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36',
'Accept-Language' => 'en-US,en;q=0.8',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Encoding' => 'gzip, deflate, sdch',
'Upgrade-Insecure-Requests' => '1',
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Connection' => 'keep-alive'
);
still no luck. any suggestions?
When I use LWP::UserAgent on that URL without your headers I get a 403 Forbidden error back. Same with curl.
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $res = $ua->get(
'http://www.nseindia.com/content/equities/scripvol/datafiles/18-08-2013-TO-17-08-2015ADANIPOWERALLN.csv');
print $res->as_string;
__END__
HTTP/1.1 403 Forbidden
Connection: close
Date: Tue, 18 Aug 2015 12:19:13 GMT
Server: AkamaiGHost
Content-Length: 388
Content-Type: text/html
Expires: Tue, 18 Aug 2015 12:19:13 GMT
Client-Date: Tue, 18 Aug 2015 12:19:13 GMT
Client-Peer: 104.85.166.76:80
Client-Response-Num: 1
Mime-Version: 1.0
Title: Access Denied
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
You don't have permission to access "http://www.nseindia.com/content/equities/scripvol/datafiles/18-08-2013-TO-17-08-2015ADANIPOWERALLN.csv" on this server.<P>
Reference #18.48a65568.1439900353.1006096e
</BODY>
</HTML>
When I added your headers, it worked the first time I tried. When I re-ran it, it also gave 404 Not Found. Now when I click the link in the browser, it gives a 404 as well.
I believe they are preventing you from dowloading the file multiple times. If you are on a dial-up connection or broadband with a non-static IP address, try to reconnect to get a fresh one, or use a proxy.
Maybe they also have terms of services that forbid using automation tools to access their ressources because they are not ment to be APIs.
Update
In fact they do not allow what you are trying to do! Point 12 of their terms of services clearly states that.
You may not conduct any systematic or automated data collection activities (including scraping, data mining, data extraction and data harvesting) on or in relation to our website without our express written consent.
In general, make your LWP user-agent look like a known browser. You can set the name of the user-agent with a parameter to new or set it later:
my $ua = LWP::UserAgent->new(
agent => ...,
);
$ua->agent( ... );
You can do other things, such as adding a cookie jar. LWP::UserAgent doesn't do that by default. Following a particular path through a website, setting referers, and other human-like behavior sometimes solve the problem. You may want to look at WWW::Mechanize for that sort of thing.
Some sites will use Javascript to do various things which your basic Perl-based user-agent can't do for you. In those cases, you might use Perl to control a UI-based browser like I show in Controlling Firefox from Perl.

PayPal Rest API Curl SSL : unable to get local issuer certificate

I am working on PayPal Express checkout restapi service.
I complated successfully at sandbox mode but when trying go online curl returns "unable to get local issuer certificate" error. At sandbox i dont get this error.
What i tried!
I tried bind cert file (Latest one from mozilla) in php.ini and curl parameter but nothing change.
Currently my code like this
//Building our NVP string
$request = http_build_query($requestParams + $params);
//cURL settings
$curlOptions = array (
CURLOPT_URL => https://api-3t.paypal.com/nvp,
CURLOPT_VERBOSE => 1,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO =>'certs/cacert.pem', //CA cert file
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $request
);
$ch = curl_init();
curl_setopt_array($ch,$curlOptions);
Where i am failing ?
Note: I already got API Signature for LIVE from
https://www.paypal.com/us/cgi-bin/webscr?cmd=_get-api-signature
I fixed problem.
Mozilla's certs is failing on live edition.
When i used Facebook's cert it fixed.

Paypal Sandbox Test Tool IPN Simulator in Localhost

How to use Instant Payment Notification Simulator in local machine? What will be provided in IPN handler URL? I don't have access to our router.
Thanks
You can test on localhost using ngrok.
Simply run ngrok locally then paste test url that ngrok gives you (something like http://1bc7d09d.ngrok.com/)
It provides a tunnel to your localhost.
Paypal's IPN simulator will not work with localhost. However, you can simulate the simulator :-). To do this you need to install a browser plugin/extension such as poster for firefox or Advanced Rest Client for google chrome.
Open the app and put in your url you are listening on for IPN responses:
http://localhost/ipn
Put the following as your POST data and submit the request:
residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&mc_fee=0.44&txn_id=421462822&receiver_email=seller%40paypalsandbox.com&custom=xyz123+CUSTOMHASH&payment_date=12%3A40%3A25+27+Aug+2013+PDT&address_country_code=US&address_zip=95131&item_name1=something&mc_handling=2.06&mc_handling1=1.67&tax=2.02&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com&notify_version=2.4&txn_type=cart&test_ipn=1&payer_status=unverified&mc_currency=USD&mc_gross=12.34&mc_shipping=3.02&mc_shipping1=1.02&item_number1=AK-1234&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street
UPDATE: I just started using another option that is easier, https://localtunnel.me. To install and run the module do the following. It will show your public URL. All requests to that public URL will be forwarded to your localhost.
npm install -g localtunnel
lt --port 80
You cannot test IPN on your localhost, as IPN is all about PayPal's server initiating a server-side POST to a URL you define.
As a result, your IPN script must be accessible by the outside world (or you can use a tunnel such as ngrok.me/localtunnel.me).
You can simulate PayPal's IPN post by running the script below I made on your localhost (you'll need curl installed). As long as your listener is pointed to the sandbox it should validate. Change your listener to the live paypal and it should fail to validate.
<?php
// SIMULATE PAYPAL IPN LOCALLY
//
// Sometimes you need to test on your local host and this can be difficult due
// to IP routing issues. Use this code on your local machine to simulate the
// same process that the sandbox IPN simulator does when posting to your URL.
//
// Run this code in command line or via the browser. It will post IPN data just
// like Paypal would. If the code you've written to process your IPN data
// posts back to the sandbox, it should come back as valid.
// Put the full url to test in $paypal_url, include file extensions if necessary
$paypal_url = 'http://localhost/paypal_ipn/process'; // IPN listener to test
//example posted data from paypal IPN
$test = 'residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&mc_fee=0.44&txn_id=421462822&receiver_email=seller%40paypalsandbox.com&custom=xyz123+CUSTOMHASH&payment_date=12%3A40%3A25+27+Aug+2013+PDT&address_country_code=US&address_zip=95131&item_name1=something&mc_handling=2.06&mc_handling1=1.67&tax=2.02&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com&notify_version=2.4&txn_type=cart&test_ipn=1&payer_status=unverified&mc_currency=USD&mc_gross=12.34&mc_shipping=3.02&mc_shipping1=1.02&item_number1=AK-1234&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street';
/*
* More detailed breakout of the raw data
_POST EXAMPLE ARRAY FROM PAYPAL:
Array
(
[residence_country] => US
[invoice] => abc1234
[address_city] => San Jose
[first_name] => John
[payer_id] => TESTBUYERID01
[mc_fee] => 0.44
[txn_id] => 421462822
[receiver_email] => seller#paypalsandbox.com
[custom] => xyz123 CUSTOMHASH
[payment_date] => 12:40:25 27 Aug 2013 PDT
[address_country_code] => US
[address_zip] => 95131
[item_name1] => something
[mc_handling] => 2.06
[mc_handling1] => 1.67
[tax] => 2.02
[address_name] => John Smith
[last_name] => Smith
[receiver_id] => seller#paypalsandbox.com
[verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AgAAjEU7A5rthY2aP4j1jOIrjuGx
[address_country] => United States
[payment_status] => Completed
[address_status] => confirmed
[business] => seller#paypalsandbox.com
[payer_email] => buyer#paypalsandbox.com
[notify_version] => 2.4
[txn_type] => cart
[test_ipn] => 1
[payer_status] => unverified
[mc_currency] => USD
[mc_gross] => 12.34
[mc_shipping] => 3.02
[mc_shipping1] => 1.02
[item_number1] => AK-1234
[address_state] => CA
[mc_gross1] => 9.34
[payment_type] => instant
[address_street] => 123, any street
)
*/
//#
// PayPal IPN processor in PHP
// fake paypal post to test scripts
//#
//----------------------------------------------------------
// Create FAKE post from PayPal.
//----------------------------------------------------------
$req = $test; // use test data
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $paypal_url);
curl_setopt($ch,CURLOPT_POST, substr_count($req,'&')+1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $req);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
?>
I do test on localhost. You can use a service like dyn.com or noip.com or point a subdomain to your local address if it's static.
/ngrok http -host-header=yourwebsite.com 80
will tunnel to localhost with the right host header