bbruman
bbruman

Reputation: 677

eBay Platform Notifications SOAP Listener Issue

I am trying to set-up eBay Platform Notifications using the official PlatformNotificationsCodeSample-PHP template.

I've configured ebay.ini successfully with my keys and tokens. With this, SetNotificationPreferences.php and GetNotificationPreferences.php both result in Success calls without issue.

With GetNotificationPreferences I can see that I successfully changed my ApplicationURL to http://localhost/notifications/listener.php

If I try to access generator.php via the command line, that returns a successful call

C:\development\xampp\htdocs\notifications>php generator.php
  <?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns1="urn:ebay:apis:eBLBaseComponents" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body><ns1:GetMemberMessagesResponseResponse><return xsi:type="xsd:string">
  trachtenberga</return></ns1:GetMemberMessagesResponseResponse>
  </SOAP-ENV:Body></SOAP-ENV:Envelope>

This coming from the $argc $notifications array and AskSellerQuestion.xml

I am just really confused as to how listener.php works.

Whether I access it directly in the browser(http://localhost/notifications/listener.php), or in the command line, I always get the following error message:

Notice: Undefined index: HTTP_RAW_POST_DATA in C:\development\xampp\htdocs\notifications\listener.php on line 107

This line being:

$stdin = $GLOBALS['HTTP_RAW_POST_DATA'];

The only possible solution I've found thus far to the Undefined index: HTTP_RAW_POST_DATA issue is to change my php.ini configuration to always_populate_raw_post_data = On, but this has no affect and I still get the same error.

I know it's been advised to use php://input instead since $HTTP_RAW_POST_DATA was depreciated in PHP 5.6.0 and removed in PHP 7.0.0, but according to the eBay Knowledge base

Please use $GLOBALS["HTTP_RAW_POST_DATA"] to capture the payload instead of file_get_contents(php://input). We have problems like clients retrieving cut-off and incomplete payloads, when they capture the PHP input stream.

How do I get this SOAP listener to work so I can start configuring my Platform Notifications?

Upvotes: 1

Views: 668

Answers (1)

bbruman
bbruman

Reputation: 677

Forgot about this thread. My solution to get this to work was simply to use

if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
}

// then do what you want, for example I was doing something like this
// to save the xml response to my web server

$file_name= "order_shipped_".time().".xml";
$stdin = $GLOBALS['HTTP_RAW_POST_DATA'];
file_put_contents($file_name, $stdin);

And I've been receiving all my notifications fine.

But with accordance to the original thread, I am not sure this is the best work-around taking into consideration the eBay Knowledge Base and the function depreciation. If anyone has any more input on this feel free to chime in :)

Upvotes: 1

Related Questions