Webhooks not working....any assistance?

Discussion in 'Troubleshooting' started by adambahr83, Jan 29, 2018.

  1. adambahr83

    adambahr83 aMember Pro Customer

    Joined:
    Mar 9, 2017
    Messages:
    14
  2. adambahr83

    adambahr83 aMember Pro Customer

    Joined:
    Mar 9, 2017
    Messages:
    14
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello,

    Are you sure your script that should handle Webhook works correctly?
    Did you try to open this webhook url in browser?

    Can you contact us in helpdesk?
    https://www.amember.com/support

    We will check what can be wrong.

    Best Regards.
  4. adambahr83

    adambahr83 aMember Pro Customer

    Joined:
    Mar 9, 2017
    Messages:
    14
    Yeah I did. The webhook URL works, it is just a slack one actually...I just was blurring out my team for no real reason.

    The script for the webhooks is just the plugin that is with aMember. Not sure what else I can do...?
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Slack expect specific data on this url and Webhooks can not be used in this case (it have its own format of data).

    Here us example of code that can be used in site.php to pass some events to Slack:
    http://www.amember.com/docs/Site.php_file

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::INVOICE_STARTED, function(Am_Event $e) {

        
    $u $e->getUser();
        
    $item $e->getInvoice()->getItem(0);

        
    $r = new Am_HttpRequest('https://hooks.slack.com/services/XXXX/XXXXX/XXXX'Am_HttpRequest::METHOD_POST);
        
    $r->setBody(json_encode(['text' => sprintf('%s sign up for %s'$u->login$item->item_title)]));
        
    $r->setHeader('Content-type''application/json');
        
    $r->send();

    });

Share This Page