doujiyun8846 2016-07-31 08:30
浏览 59
已采纳

如何将webhook数据导入查询字符串以供自定义php脚本读取?

I have a custom script in php that is intended to receive a webhook from a 3rd party CMS (specifically FLG360), search the source for records that match a given field name in the query string (using $_GET), and return/display the results.

When going to the full URL (including the query string) manually, the query string is read by the script and the correct actions are performed.

However, when sending the webhook from the CMS, it does not seem to be able to find or read the query string.

Here's the part of my script that I expected to be reading and actioning the webhook via simple $_GET requests:

$IDtoSearch = $_GET['company'];
$status = $_GET['status'];

Is pulling data from a webhook via php as simple as performing some $_GET requests? I have confirmation from the CMS support team that the webhook is definitely formatted as a query string.

I have added this to the script, in order to record any existing query string to the server's error log:

//capture the webhook and save to error log
$webhookContent = "";
$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
    $webhookContent .= fread($webhook, 4096);
}
fclose($webhook);
error_log($webhookContent);

...which is doing its job. Here's what I find in the logs after firing a webhook from the CMS:

eventtype=workflow&eventdatetime=2016-07-29+15%3A16%3A06&eventuserid=&eventusername=&id=109355632&subid=&ipaddress=217.33.80.130&received=2016-06-17+15%3A50%3A37&leadgroupid=49625&leadgroupname=zzALEX+TEST+Applicants+collections&leadtype=FIDOR+Applicant&status=Pre+Default+Applicant+%2336731&progress=Accepted&siteid=16515&sitename=FIDOR+Applicant&userid=32197&username=Aimee+Davies&buyerid=&buyername=&buyerreference=&introducerid=46437&introducername=Alex+Test+cases&reference=&source=FIDOR&medium=&term=&cost=0.00&value=0.00&transferdatetime=0000-00-00+00%3A00%3A00&transfersuccessful=No&xmldatetime=0000-00-00+00%3A00%3A00&xmlfails=0&xmlresult=&xmlreference=&appointmentdatetime=&appointmentnotes=&lastnotedatetime=0000-00-00+00%3A00%3A00&lastnote=&taskexists=No&workflowexists=Yes&dropbox=l109355632.d675cdbf4f75f7d9c6ee99a6b7034b7c%40msrvr.net&fullname=Mr.+Alex+Connor&title=Mr.&firstname=Alex&lastname=Connor&company=TFS9876543&jobtitle=&phone1=&phone2=&fax=&email=&address=&address2=&address3=&towncity=&postcode=&dob=&dobday=&dobmonth=&dobyear=&contacttime=&contactphone=Unknown&contactfax=Unknown&contactemail=Unknown&contactmail=Unknown&data1=&data2=&data3=&data4=&data5=&data6=&data7=&data8=&data9=&data10=&data11=&data12=&data13=&data14=&data15=&data16=&data17=&data18=&data19=&data20=&data21=&data22=&data23=&data24=&data25=&data26=&data27=&data28=&data29=&data30=&data31=&data32=&data33=&data34=&data35=&data36=&data37=&data38=&data39=&data40=&data41=&data42=&data43=&data44=&data45=&data46=&data47=&data48=&data49=&data50=&type1=Work+Telephone+Number&type2=TFS+Number&type3=Current+loan+balance&type4=Contracted+Monthly+Payment+Amount&type5=Last+payment+date+received&type6=Last+amount+received&type7=Next+scheduled+payment+date&type8=Current+Arrears+figure+incl+Legals%2FCharges&type9=Current+Payment+method&type10=Guarantor+is+deceased&type11=Guarantor+has+entered+DMP%2FBKO%2FIVA+&type12=Spare&type13=Actual+receipts+to+date&type14=Applicant+flat+number&type15=Applicant+house+name&type16=Applicant+house+number&type17=Guarantor+relationship+to+main+applicant&type18=Guarantor+First+Name&type19=Guarantor+Last+Name&type20=Joint+App+First+Name&type21=Joint+App+Last+Name&type22=Applicant+has+entered+DMP%2FBKO%2FIVA&type23=Current+Vienna+Status&type24=Solicitors&type25=Legal+Status&type26=Number+of+Months+in+Arrears&type27=Promise+To+Pay+DATE+%28dd%2Fmm%2Fyyyy%29&type28=Promise+To+Pay+AMOUNT&type29=Loan+Final+payment+date+%28dd%2Fmm%2Fyyyy%29&type30=Agreement+signed+date+%28FOR+DEFAULT%29+-+dd%2Fmm%2Fyyyy&type31=Default+expiry+date+%28dd%2Fmm%2Fyyyy%29&type32=Less+Rebate+of+interest+%28amount+from+settlement+letter%29&type33=Sum+Required+to+repay+loan+%28Amount+from+settlement+letter%29&type34=Default+ISSUED+date+%28dd%2Fmm%2Fyyyy%29&type35=Arrangement+Amount&type36=Arrangement+Start+Date+%28dd%2Fmm%2Fyyyy%29&type37=Arrangement+Type&type38=Arrangement+Term&type39=Arrangement+Monthly+Shortfall&type40=spare&type41=spare&type42=spare&type43=spare&type44=spare&type45=DMP%2FIVA+offer+of+Repayment&type46=Reasons+for+Arrears&type47=OFS+LETTER+3+DATE+%28dd%2Fmm%2Fyyyy%29&type48=IBC+Referance&type49=Restriction+or+Charging+order&type50=IMPORTANT+NOTES

All the information from the CMS record seems to be coming in, just not being read or recognised as a query string by my script.

Here's what I get when manually entering a query string on the URL:

, referer: https://www.domain.com/flg/index.php/?company=cream&status=cheese

Not sure what the ", referer:" part means, or why this error is being logged with the full URL as opposed to the above.

Hope somebody can help with this, I'm tearing my hair out.

Please let me know if you need any additional information.

Many thanks.

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥100 微信会员卡如何外接除本用户外的商户从而可以进行优惠支付
      • ¥50 关于github项目下载运行
      • ¥15 苹果手机删除了qq软件,qq文件怎么恢复
      • ¥20 用mips 人力编程排序问题(能在mars按要求运行)
      • ¥15 Verilog小型神经网络(单层反馈神经网络)
      • ¥15 设计一个数字钟,实现时分秒的显示
      • ¥15 Clion使用头文件链接两个cpp
      • ¥15 51单片机无法触发外部中断问题
      • ¥15 基于半监督,无监督的调制识别
      • ¥15 cst求 阵列 rcs 时候 频域 时域求解器 应该怎样设置 才让两者 计算结果 相似 请附图