Skip to content

Instantly share code, notes, and snippets.

@seanslater
seanslater / discord-webhook.php
Created June 13, 2021 13:57
Simple Discord Message Bot using Webhook
<?php
$content = 'Message to send';
$username = 'Discord Bot';
// set your own Discord webhook URL
$url = "https://discord.com/api/webhooks/00000000000000000000/000000000000000000000000000000000000000000000000000000000000";
//send message
$headers = [ 'Content-Type: application/json; charset=utf-8' ];
$POST = [ 'username' => $username, 'content' => $content ];
@seanslater
seanslater / twitch-check-live.php
Created April 11, 2020 17:04
Twitch API - Check to see if User ID is live
<?php
$TWITCH_API_KEY = ''; // your Client ID
$TWITCHUSERID = ''; // Twitch User ID number
$url = 'https://api.twitch.tv/helix/streams?user_id='.$TWITCHUSERID;
$ch = curl_init();
$headers=['Client-ID: '.$TWITCH_API_KEY];
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@seanslater
seanslater / twitch-get-userid.php
Created April 11, 2020 17:04
Twitch API - Get User ID from Username
<?php
$TWITCH_API_KEY = ''; // your Client ID
$TWITCHUSER = ''; // Twitch Username
$url = 'https://api.twitch.tv/helix/users?login='.$TWITCHUSER;
$ch = curl_init();
$headers=['Client-ID: '.$TWITCH_API_KEY];
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@seanslater
seanslater / cloudflare-dns.php
Created March 17, 2020 00:06 — forked from lewayotte/cloudflare-dns.php
Cloud Flare Automatic DNS Record Updater (PHP Script)
#!/usr/bin/php
<?php
/**
* Script used to update DNS records in Cloud Flare when server IP address changes.
* My use case is to run this script on startup, when I spin up a new Digital Ocean VPS but
* this could easily be used to update for dynamic DNS with a cronjob.
*
* Digital Ocean referral code: https://www.digitalocean.com/?refcode=3655e259ce29
*
* Requires PHP cURL
@seanslater
seanslater / remote_addr.php
Created January 6, 2016 02:36
Cloudflare DNS: Get users actual IP address (otherwise $_SERVER['REMOTE_ADDR'] will show a range of Cloudflare IPs for all users)
<?php
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
?>
@seanslater
seanslater / sendgrid_test.php
Created October 22, 2015 21:00
Send test email using SendGrid API with PHP / cURL
<?php
$url = 'https://api.sendgrid.com/';
$user = 'sendgridapiusername';
$pass = 'sendgridapipassword';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => '[email protected]',