From 2cd148c792a47fea18d760b723d23569ae52d390 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 24 Dec 2014 16:44:44 -0800 Subject: Support for "likes" and adding "settings" page * Supports a bookmarklet to create "like" posts. * Beginning a "settings" page to connect silo profiles for POSSEing likes to twitter, facebook and instagram --- lib/config.template.php | 7 +++++++ lib/helpers.php | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'lib') diff --git a/lib/config.template.php b/lib/config.template.php index df80efa..dae8968 100644 --- a/lib/config.template.php +++ b/lib/config.template.php @@ -10,5 +10,12 @@ class Config { public static $dbPassword = ''; public static $jwtSecret = 'xxx'; + + public static $fbClientID = ''; + public static $fbClientSecret = ''; + public static $twitterClientID = ''; + public static $twitterClientSecret = ''; + public static $instagramClientID = ''; + public static $instagramClientSecret = ''; } diff --git a/lib/helpers.php b/lib/helpers.php index cf751c6..010bd91 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -70,6 +70,26 @@ function get_timezone($lat, $lng) { return null; } +function micropub_post_for_user(&$user, $params) { + // Now send to the micropub endpoint + $r = micropub_post($user->micropub_endpoint, $params, $user->micropub_access_token); + + $user->last_micropub_response = json_encode($r); + $user->last_micropub_response_date = date('Y-m-d H:i:s'); + + // Check the response and look for a "Location" header containing the URL + if($r['response'] && preg_match('/Location: (.+)/', $r['response'], $match)) { + $r['location'] = $match[1]; + $user->micropub_success = 1; + } else { + $r['location'] = false; + } + + $user->save(); + + return $r; +} + function micropub_post($endpoint, $params, $access_token) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $endpoint); -- cgit v1.2.3