Created
July 28, 2016 08:22
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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