Skip to main content
Best answer

What is Zapier sending me for subscribe resthook? (PHP)


  • Beginner
  • 3 replies

Hello!

I’m working in PHP and trying to set up a resthook for the subscribeHook method. I’ve got everything working great, and when Zapier hits my endpoint, it passes the API key correctly and creates a record in the database. The trouble is that the info I need (hook_url) is empty!

 

Currently, I am expecting to find that information simply in the $_POST array as such:

$this->subscription_model->add_subscription( 'zapier', 'product_added', $_POST['product_id'], $_POST['hook_url'] );

Here is the subscribe configuration:

subscribe configuration

Do I need to be grabbing this data differently? One problem is I am not sure how to inspect the contents of what is being sent.

 

Thanks for any help you can offer!

Best answer by JackBest answer by Jack

I did actually figure this out. I’ll share some of my code in the hope that it is useful for others.

 

 $body = file_get_contents('php://input');
 $data = json_decode($body, true);
 $this->subscription_model->add_subscription( 'zapier', 'product_added', $data['product_id'], $data['hook_url'] );

I am just a somewhat newer developer and this was my first experience with using some of these concepts.

 

Good luck!

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

  • Author
  • Beginner
  • 3 replies
  • Answer
  • April 12, 2020

I did actually figure this out. I’ll share some of my code in the hope that it is useful for others.

 

 $body = file_get_contents('php://input');
 $data = json_decode($body, true);
 $this->subscription_model->add_subscription( 'zapier', 'product_added', $data['product_id'], $data['hook_url'] );

I am just a somewhat newer developer and this was my first experience with using some of these concepts.

 

Good luck!


Liz_Roberts
Forum|alt.badge.img+8
  • Zapier Staff
  • 1366 replies
  • April 13, 2020

Thanks for sharing the above code @Jack ! I’m sure this will be handy for other users. 

Happy to help should you have any other questions!