-2

A remote server will redirect with posting a JSON string back to a URL in my Drupal site defined by hook_menu. But I don't know either care the URL of the remote server. How can I get the JSON data in my hook_menu? I use these codes:

      $received = file_get_contents("drupal://input"); // Use inputstream module.
      $received = json_decode($received, TRUE);
      dpm($received);

When the redirection happened, the hook_menu page shows nothing. When I thereafter access the frontpage of my Drupal site, it shows as below:

Warning: file_get_contents(): Unable to find the wrapper "drupal" - did you forget to enable it when you configured PHP? in shisuepay_postback() (line 130 of /.../sites/all/modules/custom/shisuepay/shisuepay.module).

Warning: file_get_contents(drupal://input): failed to open stream: No such file or directory in shisuepay_postback() (line 130 of /.../sites/all/modules/custom/shisuepay/shisuepay.module).

  • I'm having a small problem understanding your question, I assume English is not your first language? Can you explain a bit more what you are trying to do? Why are you using hook_menu to do this? – Remog Nov 5 '16 at 1:01
  • What's drupal://input? Do you mean php://input, as in the raw request data excluding headers? – Clive Nov 5 '16 at 2:48
  • Yes, it should be php://input other than drupal://input – fishfree Nov 5 '16 at 13:49
0

It turned out that the postback data is not the format of JSON. So I just use $_POST variable to get the data. Thank you all the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.