Skip to content

Instantly share code, notes, and snippets.

@hideokamoto
Created May 29, 2015 12:36
Show Gist options
  • Save hideokamoto/7f5d284714ca3e3da095 to your computer and use it in GitHub Desktop.
Save hideokamoto/7f5d284714ca3e3da095 to your computer and use it in GitHub Desktop.
Twillo Shorcode Plugin
<?php
require('Services/Twilio.php');
function twilio_call(){
$account_sid = "";
$auth_token = "";
$from_num = "+81";
$to_num = "+81";
$twiml_url = "";
$client = new Services_Twilio($account_sid, $auth_token);
$call = $client->account->calls->create(
$from_num,
$to_num,
$twiml_url,
array("method" => "POST"));
echo $call->sid;
print $response;
}
twilio_call();
<?php
/**
* @package Twilio
* @version 0.0
*/
/*
Plugin Name: Twilio
Plugin URI: https://jp.twilio.com/
Description: Twillo Sample.
Author: Hidetaka Okamoto
Version: 0.0
Author URI: http://wp-kyoto.net/
*/
add_shortcode('twilio-call', 'twilio_call_btn');
function twilio_call_btn($attr){
extract(shortcode_atts(array(
'class' => 'default-class',
'text' => 'Call',
), $attr));
$call_url = plugin_dir_url( __FILE__ ) ."twilio_call.php";
$html = "<form action='{$call_url}' method='post' id='twilio-call-btn' class='{$class}'>";
$html .= "<input type='submit' value='{$text}'></form>";
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment