summaryrefslogtreecommitdiff
path: root/lib/helpers.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2014-12-27 00:08:50 +0000
committerAaron Parecki <aaron@parecki.com>2014-12-27 00:08:50 +0000
commit87a76f495eb3126e6d3adb5bf675fdb41682a16d (patch)
tree79b37a3c90955787f28ec4578c7112a44e39c505 /lib/helpers.php
parent89afcc13490b7f89ddd1301394acef34682d52b2 (diff)
parent875a9fd90944eef8bf94f24594c80b9433ec824d (diff)
Merge branch 'master' of github.com:aaronpk/IndiePost
Diffstat (limited to 'lib/helpers.php')
-rw-r--r--lib/helpers.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index cf751c6..9993231 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'] = trim($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);
@@ -175,3 +195,14 @@ function relative_time($date) {
}
return $rel->timeAgo($date);
}
+
+function instagram_client() {
+ return new Andreyco\Instagram\Client(array(
+ 'apiKey' => Config::$instagramClientID,
+ 'apiSecret' => Config::$instagramClientSecret,
+ 'apiCallback' => Config::$base_url . 'auth/instagram/callback',
+ 'scope' => array('basic','likes'),
+ ));
+}
+
+