REST API 400 Bad Request

damcompany
Contributor
Contributor

 

Hello, by today I receive payments from my game www.footballherogame.it, but users doesn't receive the money game they've bought.

I've tried to check my code

fputs($fp, $header . $req);
while(!feof($fp)){
$res = fgets($fp, 1024);

//if paypal said is VERIFIED
if(strtoupper(trim($res)) == "VERIFIED"){

//do things

}

I've looked that $res now it's not VERIFIED even if I receive the payment from the user, but I get

 

The requested URL "&#91;no&#32;URL&#93;", is invalid.<p> 

HTTP/1.0 400 Bad Request

<TITLE>Invalid URL</TITLE>

 
Could somebody help me?
Login to Me Too
7 REPLIES 7

damcompany
Contributor
Contributor

Anyone?

Login to Me Too

boba001
Contributor
Contributor

 

This is a "me too" reply: getting exactly the same errors, starting some time about 4-6 days ago.

 

Will post of course when I find out the cause..

 

For completeness, I'm using this call and parameters:

$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];

$auth_token = "(my auth token)";

$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

 

Login to Me Too

damcompany
Contributor
Contributor

Yes, exactly same problem and code...but I use

$req = 'cmd=_notify-validate';

 

Could someone help us?

Login to Me Too

ilventodellest
New Community Member

I have the same problem till 12 sett 2018

 

I recive this erorr:

 

HTTP/1.0 400 Bad Request
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 209
Expires: Thu, 13 Sep 2018 10:28:07 GMT
Date: Thu, 13 Sep 2018 10:28:07 GMT
Connection: close
Invalid URL

The requested URL "[no URL]", is invalid.
Reference #9.55b5655f.1536834487.1bd5c063

 

is it paypal server problem?

Please help!

Login to Me Too

boba001
Contributor
Contributor

@ilventodellest wrote:

is it paypal server problem?

Please help!


It's either that, or there was some API change we missed.

 

I'm browsing the changelog now: https://developer.paypal.com/docs/release-notes/release-notes-2018/#

 

 

Login to Me Too

gsu
Contributor
Contributor

 

You have to update your scripts to HTTP 1.1

 

1.  modify the posted Header information from  

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";

into 

$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";

 

2. add the Host variable to the header   that is typically missing in HTTP 1.0 requests!

 so add a line like

$header .= "Host: www.paypal.com\r\n";

if your script communicates with www.paypal.com  or  

change it to the proper used endpoint host  like   ipnpb.paypal.com 

 

good luck  Smiley Wink

Login to Me Too

boba001
Contributor
Contributor

 

Thank you  Smiley Very Happy

 

That's so easily overlooked, thanks a lot.

 

The silly thing is, in a different part of the site there's also some "purchase code",

and it uses curl, which works fine.. (should've compared the two a bit better..)

 

(test it out by getting a subscription at https://www.calcudoku.org  Smiley Tongue)

 

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.