Skip to content

Instantly share code, notes, and snippets.

@brendandawes
Created July 28, 2016 08:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brendandawes/9d2400dac9ce31d523a7bd19f652dc73 to your computer and use it in GitHub Desktop.
Save brendandawes/9d2400dac9ce31d523a7bd19f652dc73 to your computer and use it in GitHub Desktop.
IFTTT Make channel action to create blog post from new post on Instagram
<?php
/*
Action to create a blog post entry in my Kirby powered site via an IFTTT recipe. In IFTTT I have a an Instagram trigger that calls
this script, sending a POST using the Maake channel with this body: params={{EmbedCode}}&caption=<<<{{CaptionNoTag}}>>>
*/
if((isset($_POST['params']))){
$subject = urldecode($_POST['caption']);
$text = stripslashes($_POST['params']);
$i = 0;
$dir = '../content/05-blog/';
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false){
if (is_dir($dir.$file))
$i++;
}
}
$body = "";
$body .= "Title: ".$subject."\n----\n\n";
$body .= "Date: ".date("Y-m-d")."\n----\n\n";
$body .="Text: ".$text."\n\n----\n\n";
$body .="blogid: ".$i."\n\n----\n\n";
$urldir = date("Y-m-d")."-".$i;
$dirname = $i."-".$urldir;
mkdir($dir.$dirname);
$fullpath = $dir.$dirname."/article.txt";
file_put_contents($fullpath,$body);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment