İnstagram İçin Bot Php
-
arkadaşlar instagram için php bot buldum ancak naısl kullanabilecegim hakkında pek bilgim yok tamam php yazılmış ancak nereleri editlemem lazım bilgisi olanb irisi yardımcı olabilirmi
kod ve yazan kişinin yorumu bu nasıl yapabilrim ?
Instagram için bot
Iphone kullanıcıları için artık bir alışkanlık haline gelmiş mobil internette çığır açmış 29 milyon üyeye 1 yıl gibi bir sürede ulaşmış bir program var. Çoğumuz adını haber sitelerinde görmüşüzdür.
Bu programa insanlar çektiği fotgraflara efekt vererek paylaşmalarını sağlıyor. Yakın zamanda anroid telefonlar içinde çıkacağı duyuruldu.
Birde bu şirket instagram API diye bir şey çıkardı. Resimlere erişebilme beğenme yorum atma gibi özellikler sunuyor. Bu API kullanımı.
Kendi applicationunuzu yapabiliyorsunuz internet üzerinde veya iphone için.
Bende bir deniyim dedim fazla kodlama bilmeme rağmen epey bir şey yaptım ve başarıyla sonuçlandı.
1 günde 50000 tane fotograf beğeniyor yaptığım uygulama ve takipçi sayısını 1 günde 0 dan 900 lere kadar çıkardı.
Yazdığım program PHP ve başka bir elemeanın yaptığı acess kodlarını kullanarak bağlandım Instagram API ye.
Bu konuda yardımcı olabilecek veyahut ilgilenen arkadaşlar varsa kaynak kodunu paylaşmak isterim. Bu işten epey gelir elde edilebilir olmadı epey insan toplanılabilir...
Selametle (F)
Dosyalar Şu Şekilde
index.php ::
###################################################################
<meta http-equiv="Refresh" content="50">
<?php
session_start();
require_once ’src/config.php’;
require_once ’src/Instagram.php’;
$access_token = isset($_SESSION[’access_token’]) ? $_SESSION[’access_token’] : null;
$instagram = new Instagram(CLIENT_ID, CLIENT_SECRET, $access_token);
if(!$access_token){
// If there is no access token in the session, let’s have the user authenticate our application...
/*
/ You pass the Redirect Uri you registered with your app and an array of "scope" (aka permissions) you
/ want to grab from the user. There is also a third parameter "response_type" which defaults to "code"
*/
$loginUrl = $instagram->authorizeUrl(REDIRECT_URI, array(’basic’, ’comments’, ’likes’, ’relationships’));
} else {
try {
$feed = $instagram->get(’/tags/jj/media/recent’);
$feed4 = $instagram->get(’/tags/girl/media/recent’);
$feed2 = $instagram->get(’/tags/iphoneonly/media/recent’);
}catch(InstagramApiError $e) {
die($e->getMessage());
}
}
?>
<?php if(isset($loginUrl)): ?>
<a href= "<?php echo $loginUrl; ?>">Log in</a>
<?php else: ?>
<ul>
<?php foreach($feed->data as $item): ?>
<li>
ID: <?php echo $item->id; ?><br />
<?php $instagram->post(’media/’.$item->id.’/likes’); ?>
</li>
<hr>
<?php endforeach; ?>
</ul>
<ul>
<?php foreach($feed2->data as $item): ?>
<li>
ID: <?php echo $item->id; ?><br />
<?php $instagram->post(’media/’.$item->id.’/likes’); ?>
</li>
<hr>
<?php endforeach; ?>
</ul>
<ul>
<?php foreach($feed4->data as $item): ?>
<li>
ID: <?php echo $item->id; ?><br />
<?php $instagram->post(’media/’.$item->id.’/likes’); ?>
</li>
<hr>
<?php endforeach; ?>
</ul>
<?php endif; ?>
###################################################################
callback.php
###################################################################
<?php
session_start();
require_once ’src/config.php’;
require_once ’src/Instagram.php’;
$instagram = new Instagram(CLIENT_ID, CLIENT_SECRET, null);
if(isset($_GET[’error’]) || isset($_GET[’error_reason’]) || isset($_GET[’error_description’])){
// Throw error message... the user might have pressed Deny.
}
// If there is no error, we should try and grab an access token that we can store in a database or something
// for future use if the user revisits our application
/*
/ Pass the code that you get back from the Authorization call and pass the Redirect URI
/ There is a third parameter "grant_type" which defaults to "authorization_code" (limited by Instagram, currently)
*/
$access_token = $instagram->getAccessToken($_GET[’code’], REDIRECT_URI);
$_SESSION[’access_token’] = $access_token->access_token;
// Do what you want with the access token, maybe store it in a database?
// Close window or redirect the user back to our index.php so we can pull in some data.
header("Location: index.php");
//exit(’<script> window.close(); </script>’);
?>
###################################################################
src/confiq.php
###################################################################
<?php
define(’CLIENT_ID’, ’CLİENT ID’);
define(’CLIENT_SECRET’, ’CLIENT SECRET’);
define(’REDIRECT_URI’, ’REDIRECT URL’);
?>
###################################################################
src/instagram.php
###################################################################
<?php
class Instagram {
private $apiBase = ’https://api.instagram.com/’;
private $apiUrl = ’https://api.instagram.com/v1/’;
protected $client_id;
protected $client_secret;
protected $access_token;
public function accessTokenUrl() { return $this->apiBase.’oauth/access_token/’; }
public function authorizeUrl($redirect_uri, $scope = array(’basic’), $response_type = ’code’){
return $this->apiBase.’oauth/authorize/?client_id=’.$this->client_id.’&redirect_uri=’.$redirect_uri.’&response_type=’.$response_type.’&scope=’.implode(’+’, $scope);
}
public function __construct($client_id=’’, $client_secret=’’, $access_token = ’’)
{
if(empty($client_id) || empty($client_secret)){
throw new Exception(’You need to configure your Client ID and/or Client Secret keys.’);
}
$this->client_id = $client_id;
$this->client_secret = $client_secret;
$this->access_token = $access_token;
}
private function urlEncodeParams($params)
{
$postdata = ’’;
if(!empty($params)){
foreach($params as $key => $value)
{
$postdata .= ’&’.$key.’=’.urlencode($value);
}
}
return $postdata;
}
public function http($url, $params, $method)
{
$c = curl_init();
// If they are authenticated and there is a access token passed, send it along with the request
// If the access token is invalid, an error will be raised upon the request
if($this->access_token){
$url = $url.’?access_token=’.$this->access_token;
}
// If the request is a GET and we need to pass along more params, "URL Encode" them.
if($method == ’GET’){
$url = $url.$this->urlEncodeParams($params);
}
curl_setopt($c, CURLOPT_URL, $url);
if($method == ’POST’){
curl_setopt($c, CURLOPT_POST, True);
curl_setopt($c, CURLOPT_POSTFIELDS, $params);
}
if($method == ’DELETE’){
curl_setopt($c, CURLOPT_CUSTOMREQUEST, ’DELETE’);
}
curl_setopt($c, CURLOPT_RETURNTRANSFER, True);
$r = json_decode(curl_exec($c));
// Throw an error if maybe an access token expired or wasn’t right
// or if an ID doesn’t exist or something
if(isset($r->meta->error_type)){
throw new InstagramApiError(’Error: ’.$r->meta->error_message);
}
return $r;
}
// Giving you some easy functions (get, post, delete)
public function get($endpoint, $params=array(), $method=’GET’){
return $this->http($this->apiUrl.$endpoint, $params, $method);
}
public function post($endpoint, $params=array(), $method=’POST’){
return $this->http($this->apiUrl.$endpoint, $params, $method);
}
public function delete($endpoint, $params=array(), $method=’DELETE’){
return $this->http($this->apiUrl.$endpoint, $params, $method);
}
public function getAccessToken($code, $redirect_uri, $grant_type = ’authorization_code’){
$rsp = $this->http($this->accessTokenUrl(), array(’client_id’ => $this->client_id, ’client_secret’ => $this->client_secret, ’grant_type’ => $grant_type, ’redirect_uri’ => $redirect_uri, ’code’ => $code), ’POST’);
return $rsp;
}
}
class InstagramApiError extends Exception {}
?>sayfasıda bu : http://www.teknolojioku.com/forum/Konu-Instagram-i%C3%A7in-bot-7863.html -
yokmu php ci bir arkadaş bi el atsa ?
-
anladığım kadarıyla instagram api'si için kaydolup
define(’CLIENT_ID’, ’CLİENT ID’);
define(’CLIENT_SECRET’, ’CLIENT SECRET’);
define(’REDIRECT_URI’, ’REDIRECT URL’);kayıtla birlikte gelen bilgileri yukarıdaki bölümlere girmeniz gerekiyor, 2 kısımlara
-
define(’CLIENT_ID’, ’xxxxx’);
define(’CLIENT_SECRET’, ’xxxxxxx’);
define(’REDIRECT_URI’, ’xxxxxx’);xxxx lere api bilgilerini gireceksin.
Toplam Hit: 1591 Toplam Mesaj: 4
