Browse Source

webhook update

master
Felty 1 year ago
parent
commit
774f24bf02
3 changed files with 40 additions and 8 deletions
  1. +30
    -5
      vidyen-discord-webhook/includes/functions/vidyen-discord-webhook-function.php
  2. +6
    -2
      vidyen-discord-webhook/includes/shortcodes/vidyen-discord-webhook-shortcode.php
  3. +4
    -1
      vidyen-discord-webhook/vidyen-discord-webhook.php

+ 30
- 5
vidyen-discord-webhook/includes/functions/vidyen-discord-webhook-function.php View File

@ -4,15 +4,40 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function vidyen_discord_webhook_func($message, $username, $url)
{
$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => array("content" => $message, "username" => $username),
'cookies' => array()
)
);
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
$response = $error_message;
//echo "Something went wrong: $error_message";
}
else
{
//echo 'Response:<pre>';
//print_r( $response );
//echo '</pre>';
$result = $response;
}
//Curl was giving too many issues
/*
$data = array("content" => $message, "username" => $username);
$curl = curl_init($url);
$curl = curl_init("{$url}");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
return curl_exec($curl);
}
function vidyen_discord_message_generator()
{
*/
return $result;
}

+ 6
- 2
vidyen-discord-webhook/includes/shortcodes/vidyen-discord-webhook-shortcode.php View File

@ -6,9 +6,13 @@ function vidyen_discord_webhook_test_func()
{
$message = 'Here arrives the great and terrible webhook!';
vidyen_discord_webhook_func($message);
$username = 'Webhook';
return 'Hello! It has run!'
$url = '';
vidyen_discord_webhook_func($message, $username, $url);
return 'Hello! It has run!';
}

+ 4
- 1
vidyen-discord-webhook/vidyen-discord-webhook.php View File

@ -3,7 +3,7 @@
Plugin Name: VidYen Discord Webhooks
Plugin URI: https://wordpress.org/plugins/vidyen-point-system-vyps/
Description: VidYen Webhook posting for VidYen
Version: 0.0.1
Version: 0.0.6
Author: VidYen, LLC
Author URI: https://vidyen.com/
License: GPLv2
@ -28,6 +28,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*** SHORTCODE INCLUDES IN BASE ***/
include( plugin_dir_path( __FILE__ ) . 'includes/shortcodes/vidyen-discord-webhook-shortcode.php'); //Point Log
/*** Functions ***/
include( plugin_dir_path( __FILE__ ) . 'includes/functions/vidyen-discord-webhook-function.php'); //Point Log
/*** AJAX ***/
//include( plugin_dir_path( __FILE__ ) . 'includes/functions/ajax/vyps_ajaxurl.php'); //Forces ajax to be called regardless of installation
//include( plugin_dir_path( __FILE__ ) . 'includes/functions/ajax/vyps_mo_ajax.php'); //MO Pull ajax

Loading…
Cancel
Save