0

I have been asked to write a program that takes a list of numbers and sends a post to ms.4url.eu via JSON/HTTP Post in format:

{
  "username":"a", 
  "password":"b", 
  "msisdn":"071231231234", 
  "webhook":"http://example.com"
} 

it receives a JSON Response,

{
  "status":"ok",
  "id":"1234-1234-12344423-123123"
}

I have been told I can use ngrok for the webhook and I have to send a HTTP Response 200 within 1s.

I should receive a Webhook Response:

{
  "id":"1234-1234-12344423-123123",
  "msisdn":"071231231234",
  "status":"unavaliable",
  "error":"1b",
  "errorDesc":"Abscent Subscriber"
}

How would I go about grabbing the data from the JSON response and Responding with a HTTP 200 in order to receive the second response with the data?

I can get the first response in curl but I am unable to get the webhook working to a php file using ngrok and HTTP response sent to request the main information in the second response.

Edited : I have executed the curl command,

curl -H 'content-type: application/json' \ 
     -d '{"username":"a", "password":"b", "msisdn":"07123123124","webhook":"http://example.com/"}' \
     HTTPS://ms.4url.eu/lookup            

of which I get the first response "status ok". I would like to know how to get the response(Json format) in php using http post to the URL and the using a webhook to respond with 1second with a http 200 response to receive the further information from the API URL.

Jason
  • 2,507
  • 20
  • 25
Ollie Beumkes
  • 301
  • 2
  • 17
  • Please show what you've tried so far, and explain how it's not working. Do you get error messages? Incorrect response? No response? etc. That way, it'll be possible to give you some helpful words instead of guesses. – Jason Dec 05 '16 at 22:46
  • Hi Jason thanks for the response, basically I have executed the curl command, curl -H 'content-type: application/json' -d '{"username":"a", "password":"b", "msisdn":"07123123124","webhook":"http://example.com/"}' HTTPS://ms.4url.eu/lookup of which I get the first response "status ok". I would like to know how to get the response(Json format) in php using http post to the URL and the using a webhook to respond with 1second with a http 200 response to receive the further information from the API URL – Ollie Beumkes Dec 05 '16 at 23:13
  • Great info. This isn't my area of expertise, so I don't have an answer for you. But if you edit your question to include the info you've provided in your comment, you'll get must faster responses. More people will reply if they don't have to scroll down to the comments to see whether or not they can understand what's going on. Good luck! – Jason Dec 05 '16 at 23:29
  • Thanks Jason I know is a bit of a vague question but really stuck haha take care buddy – Ollie Beumkes Dec 05 '16 at 23:31

1 Answers1

-1

I ended up using ngrok and viewing the Raw POST response and getting the JSON and viewing the Raw data I still had more code to do in order t make this question valid as there are too many points to answer.

Ollie Beumkes
  • 301
  • 2
  • 17