APIs & Integrations

ariel_cu4tro
Member | Platinum Partner
Member | Platinum Partner

Send info of webhook to api php

i have workflow and send webhook when i create a ticket, this info send to a page web external (php) but no recieve nothing. I recieve with "print_r($_POST)"

0 Upvotes
3 Replies 3
lscanlan
HubSpot Alumni
HubSpot Alumni

Send info of webhook to api php

Hi @ariel_cu4tro,

 

Could you give us some more details about how you're receiving the webhook data? I think I might have found the workflow that you're referring to (ID 2276654). I'm seeing 142 enrollments and when I look at the history I'm seeing succesful POSTs for the webhooks. So I'm wondering if there's something about the way you're receiving the data that's just not picking up the payload. Or if there's another workflow that I should be looking at, let me know. And are you able to receive the webhooks from other workflows, but just not this one?

 

 - Leland

Leland Scanlan

HubSpot Developer Support
0 Upvotes
starrcopaul
Participant

Send info of webhook to api php

Different person, same problem.  I can see the data using TCPdump:

 

15:24:15.899792 IP (tos 0x0, ttl 64, id 57974, offset 0, flags [DF], proto TCP (6), length 1098)
10.11.101.120.50596 > 10.11.101.170.80: Flags [P.], cksum 0x1dd5 (correct), seq 1:1047, ack 1, win 502, options [nop,nop,TS val 1910695502 ecr 4253394573], length 1046: HTTP, length: 1046
POST /webhooks/hubspot/ HTTP/1.1
Host: www1.xxxxxx.xxx
X-HubSpot-Signature: 708ec3d35c156d2198f2f0ea9afa238f53703a8fa7df7656c9f59ae9181d909d
X-HubSpot-Signature-Version: v1
Content-Type: application/json
User-Agent: HubSpot Connect 2.0 (http://dev.hubspot.com/) - WebhooksExecutorDaemon-executor
X-HubSpot-Timeout-Millis: 10000
X-Trace:
accept: */*
X-Forwarded-For: 54.174.55.139
X-Forwarded-Host: webhooks.xxxxx.com
X-Forwarded-Server: webhooks.xxxxx.com
Connection: Keep-Alive
Content-Length: 525

[{"eventId":303578749,"subscriptionId":xx48xx,"portalId":xxxxx,"appId":xx42xx,"occurredAt":1597868655244,"subscriptionType":"contact.propertyChange","attemptNumber":0,"objectId":xxxxx,"propertyName":"phone","propertyValue":"3143212222","changeSource":"CRM_UI"},{"eventId":1340858813,"subscriptionId":xx48xx,"portalId":xxxxx,"appId":xx42xx,"occurredAt":1597868655244,"subscriptionType":"contact.propertyChange","attemptNumber":0,"objectId":xxxx,"propertyName":"lastname","propertyValue":"Hoch","changeSource":"CRM_UI"}][!http]

 

I've tried var_dump'ing, printf'ing, json_decode'ing, foreach looping, etc, etc.  I'm at a loss as to what else to try.  At this point I'm just trying random solutions found online for interpretting JSON POST payloads in PHP.  No joy..... 😞

 

Do you have a simple example for receiving webhook data with PHP?  Currently all I seem to be getting is the content length, which isn't terribly helpful. 

 

I'm probably just doing/missing something dumb...

0 Upvotes
starrcopaul
Participant

Send info of webhook to api php

I was doing something dumb...  Super simple... This will get you data in PHP:

 

$json = file_get_contents('php://input');
error_log($json);

You can do fancy stuff with it after putting it in an array:

$json = file_get_contents('php://input');
$response=json_decode($json, TRUE);

Just a foreach will work.