Skip to content

Instantly share code, notes, and snippets.

View HootsuiteJosh's full-sized avatar

HootsuiteJosh

View GitHub Profile
@HootsuiteJosh
HootsuiteJosh / memberApp.php
Created March 29, 2018 01:38
Member app workflow using Guzzle and PHP
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
const HOOTSUITE_CLIENT_ID = 'yourclientid'; // your client ID and secret are available through the developer dash
const HOOTSUITE_CLIENT_SECRET = 'yourclientsecret'; // if you don't have API access yet, email app.directory@hootsuite.com
$member_id = '123'; // the memberId of a user of your Hootsuite app, available through the dashboard SDK
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
const HOOTSUITE_CLIENT_ID = 'yourclientid'; // your client ID and secret are available through the developer dash
const HOOTSUITE_CLIENT_SECRET = 'yourclientsecret'; // if you don't have API access yet, email app.directory@hootsuite.com
$member_id = '17107276'; // the memberId of a user of your Hootsuite app, available through the dashboard SDK
@HootsuiteJosh
HootsuiteJosh / publishing_with_a_target.php
Created February 10, 2018 01:06
Facebook publishing through Hootsuite with advanced targeting options (using Guzzle)
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
const HOOTSUITE_ACCESS_TOKEN = 'your Hootsuite oauth token'; // obtained through OAuth
const FACEBOOK_PAGE_SOCIAL_PROFILE_ID = "121476024"; // obtain this through the socialProfiles API
$hsClient = new Client([
'headers' => ['Authorization' => 'Bearer ' . HOOTSUITE_ACCESS_TOKEN]
@HootsuiteJosh
HootsuiteJosh / owly.php
Created January 31, 2018 23:16
Upload an owl image to the Ow.ly API then post it through Hootsuite
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
const OWLY_KEY = 'your Ow.ly API'; // contact dev.support@hootsuite.com if you need one!
const HOOTSUITE_ACCESS_TOKEN = 'your token'; // obtained through OAuth
$owlyClient = new Client([
'base_uri' => 'http://ow.ly'
@HootsuiteJosh
HootsuiteJosh / twitter_oauth.json
Created January 4, 2018 20:54
Postman collection for working with 🐦
{
"info": {
"name": "Twitter OAuth",
"_postman_id": "b18dd2c3-294a-9b0b-4150-8662dfab3cd0",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get an oauth_token",
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
// ...
public String computeHash(String uId, String ts, String secret) {
byte[] digest = DigestUtils.sha512(uId + ts + secret);
char[] hex = Hex.encodeHex(digest);
return new String(hex);
}
@HootsuiteJosh
HootsuiteJosh / outbound_messages.php
Created November 3, 2017 21:02
Fetch outbound messages from the past week with PHP and the cURL extension
<?php
$token = 'your-token-here';
$params = array(
'startTime' => date(DATE_ISO8601, time()-24*60*60*7),
'endTime' => date(DATE_ISO8601, time())
);
$url = "https://apis.hootsuite.com/v1/messages?" . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));