0

I am trying to receive a shoppy webhook and put it in my database. But there for I am first sending it to the discord webhook using json_encode. To see what the $_POST variable contains.

function postToDiscord($message, $webhook)
{
    $data = array("content" => $message, "username" => "TEST");
    $curl = curl_init($webhook);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    return curl_exec($curl);
}

postToDiscord(json_encode(utf8ize($_POST)), "WEBHOOK WAS HERE");

Here is a link to the Shoppy api; click. It says it should deliver the information with $_POST, but when I use the webhook simulator, I only receive []. Does somebody has a solution for this?

Arby Hotel
  • 19
  • 1
  • 4
  • _“It says it should deliver the information with $_POST”_ - where exactly does it say that? – misorude Nov 29 '18 at 08:38
  • Not sure what exactly your problem is from your description, but it sounds like this might simply be a duplicate of https://stackoverflow.com/questions/18866571/receive-json-post-with-php – misorude Nov 29 '18 at 08:38
  • If I remember correctly, `curl_setopt($curl, CURLOPT_POSTFIELDS, $data);` I don't need to add json_encode here? – Luna Nov 29 '18 at 08:40

0 Answers0