简体   繁体   中英

Get PHP response into Zapier webhook

I am connecting PipeDrive with Post Affiliate Pro (with it's API) and am using Zapier webhooks (POST). Therefore I use PHP scripts on my server in which I talk to Post Affiliate Pro. So I have variables in my PHP script which I need to return in order to use them in another webhook/or general action step. In Zapier the only variable I get when testing the step is a String with my response message (and whatever variable I put in there). But I need to get all variables on their own (I guess all in a JSON).

So my question is: How can I return variables in an HTTP POST request to make them available (in the dropdown list?) in Zapier to use them in the next webhook?

At the moment I have something like this:

if ($result->isError()) {
 echo 'Error: '.$result->getErrorMessage();
} else {
 //echo 'Ok: '.$result->getInfoMessage();
 echo json_encode($orderID);

I am using 'echo' but I've also tried to use 'return' which didn't lead to any results. I've also tried to use json_encode to return a JSON but without luck. Or do I even need to use another Zapier step? Or am I not able to return values with a POST webhook at all? Do I need to use a "Catch Hook" webhook? I am completely new to Zapier and PHP.

Image shows just two Strings ('Text' & 'Text Transaktion') available in Zapier but no other variables

Thanks for your help!

I finally found it out by myself. I have to return one JSON, which includes everything. It's also not possible to echo anything at the same time as this would result in the output of just one string with all the values in it (like I had it before).

So something like this does the job:

if (!isset($returnValue)) {
  $returnValue = new stdClass();
  $returnValue->order_id = $orderID;
  $returnValue->result_message = $resultMessage;
}

print_r(json_encode($returnValue));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM