Skip to content

Instantly share code, notes, and snippets.

@mhcifci
Last active September 9, 2018 15:47
Show Gist options
  • Save mhcifci/481d2e2733f3ca724a2b566d4ce704b8 to your computer and use it in GitHub Desktop.
Save mhcifci/481d2e2733f3ca724a2b566d4ce704b8 to your computer and use it in GitHub Desktop.
Downloading instagram photos with link function
<?php
/**
*
* Author: Mahmut Can
* Date: 20.07.2018
* # Instagram Photo Downloader #
*
**/
Function Conn($link){ // I create a link function.
$like = curl_init();
curl_setopt($like, CURLOPT_URL, $link); //
curl_setopt($like, CURLOPT_RETURNTRANSFER, true);
curl_setopt($like, CURLOPT_SSL_VERIFYHOST, false); // I edit https address
curl_setopt($like, CURLOPT_SSL_VERIFYPEER, false); // I edit https address
$try = curl_exec($like);
curl_close($like);
return $try;
}
# I am receiving a data with post
trim($_POST["dw"]); // trimming data
$link = Conn($_POST["dw"]); // im connection to get link
preg_match('@<meta property="og:image" content="(.*?)" />@si', $link, $ImageRoad); // i match instagram photo source to post link
$dwlink=$ImageRoad["1"]; // and i switch necessary to array
?>
<!DOCTYPE html>
<html>
<head>
<!-- Google Fonts; Play -->
<link href="https://fonts.googleapis.com/css?family=Play" rel="stylesheet">
<!-- Title -->
<title>Instagram Photo Downloader</title>
<!-- Animate.CSS; thanks to Daniel Eden -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<style>
/*
*
* Web Page Style Code
*
*/
body {
background: #c31432; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #240b36, #c31432); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #240b36, #c31432); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
font-family: Play;
}
input[type=text] {
width: 30%;
padding: 12px 15px;
margin: 8px 0;
box-sizing: border-box;
font-family: Play;
}
.button {
background: #0f2027; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #0f2027, #203a43, #2c5364);
background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
font-size: 13px;
margin: 4px 2px;
cursor: pointer;
font-family: Play;
}
h3 {
color: white;
}
img {
padding-top: 35px;
}
.centertocenter {
padding-top: 200px;
}
/*
*
* Web Page Style Code
*
*/
</style>
</head>
<body>
<center>
<div class="centertocenter">
<h3>Just paste Instagram Photo Link</h3>
<form action="" method="POST">
<input class="animated animated pulse" type="text" name="dw" placeholder="https://www.instagram.com/p/BlYk8ufDBBx/?taken-by=instagram" required="">
<button class="button" type="submit">Control</button>
</form>
<?php if ($_POST) {?>
<img style="width: 350px;" src="<?php echo $dwlink; ?>"><br><br>
<a href="<?php echo $dwlink."?dl=1" ?>" type="button" class="button">Download</a><br><br>
<?php } else {echo "";} ?>
</div>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment