简体   繁体   English

将PHP响应发送到Zapier Webhook

[英]Get PHP response into Zapier webhook

I am connecting PipeDrive with Post Affiliate Pro (with it's API) and am using Zapier webhooks (POST). 我正在将PipeDrive与Post Affiliate Pro(具有API)连接,并正在使用Zapier Webhooks(POST)。 Therefore I use PHP scripts on my server in which I talk to Post Affiliate Pro. 因此,我在与Post Affiliate Pro通讯的服务器上使用PHP脚本。 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. 因此,我的PHP脚本中有一些变量,我需要返回这些变量才能在另一个webhook /或常规操作步骤中使用它们。 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). 在Zapier中,测试该步骤时获得的唯一变量是带有响应消息的String(以及放置在其中的任何变量)。 But I need to get all variables on their own (I guess all in a JSON). 但是我需要自己获取所有变量(我想所有变量都放在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? 所以我的问题是:如何在HTTP POST请求中返回变量以使其在Zapier中可用(在下拉列表中?),以便在下一个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. 我使用的是'echo',但我也尝试使用'return'并没有导致任何结果。 I've also tried to use json_encode to return a JSON but without luck. 我也尝试过使用json_encode返回JSON,但是没有运气。 Or do I even need to use another Zapier step? 还是我甚至需要使用另一个Zapier步骤? Or am I not able to return values with a POST webhook at all? 还是我根本无法通过POST网络挂钩返回值? Do I need to use a "Catch Hook" webhook? 我是否需要使用“抓钩”网络钩? I am completely new to Zapier and PHP. 我对Zapier和PHP完全陌生。

Image shows just two Strings ('Text' & 'Text Transaktion') available in Zapier but no other variables 该图显示了Zapier中只有两个字符串(“文本”和“文本转换”),但没有其他变量

Thanks for your help! 谢谢你的帮助!

I finally found it out by myself. 我终于自己找到了。 I have to return one JSON, which includes everything. 我必须返回一个JSON,其中包括所有内容。 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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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