wmaraci reklam

Smm Panel api sistemi nasıl çalışır ?

3 Mesajlar 2.323 Okunma
wmaraci reklam

emulnurullah emulnurullah Payerme.com Kullanıcı
  • Üyelik 03.06.2019
  • Yaş/Cinsiyet 25 / E
  • Meslek Teknisyen
  • Konum Manisa
  • Ad Soyad N** E**
  • Mesajlar 180
  • Beğeniler 34 / 35
  • Ticaret 0, (%0)
İyi günler arkadaşlar smm panel scripti yazmaya çalışıyorum ama api sisteminde takıldım api nasıl çalışıyor uzak mysql ile bağlanıp verilerini ana bayiye mi bildiriyoruz yoksa o mu web sitemizden çekiyor veya nasıl işliyor bu api sistemi cevaplarınız için şimdiden teşekkürler:)
 

 

Telegram botlarınızı yapabilirim, iletişim t.me/emulnurullah
SMM Panel, Sosyalyuvam, Bayilik Paneli, En Uygun Panel, Takipçi Paneli
reklam

awoken awoken WM Aracı Kullanıcı
  • Üyelik 06.06.2019
  • Yaş/Cinsiyet 19 / E
  • Meslek Öğrenci
  • Konum Diğer
  • Ad Soyad B** G**
  • Mesajlar 1002
  • Beğeniler 250 / 478
  • Ticaret 41, (%100)
Ana bayinin bir sistemi oluyor. Kendi user listeleri falan var, istedikleri kullanıcıya takipçi gönderiyorlar mesela. Sana bir api adresi veriyorlar.
Örnek: http://smm/api/takipci?key=apikey&username=kullaniciadi&miktar=1000
Sen bu api adresine istekte bulunuyorsun ve apiden yanıt bekliyorsun. Umarım anlatabildim.
emulnurullah

kişi bu mesajı beğendi.

MehmetMasa MehmetMasa WM Aracı Kullanıcı
  • Üyelik 05.10.2016
  • Yaş/Cinsiyet 26 / E
  • Meslek Yazılımcı
  • Konum İzmir
  • Ad Soyad M** M**
  • Mesajlar 1946
  • Beğeniler 552 / 554
  • Ticaret 40, (%100)
Curl kodları ;


class Api
{
public $api_url = ''; // API URL
public $api_key = ''; // Your API key

public function order($data) { // add order
$post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
return json_decode($this->connect($post));
}

public function status($order_id) { // get order status
return json_decode($this->connect(array(
'key' => $this->api_key,
'action' => 'status',
'order' => $order_id
)));
}

public function multiStatus($order_ids) { // get order status
return json_decode($this->connect(array(
'key' => $this->api_key,
'action' => 'status',
'orders' => implode(",", (array)$order_ids)
)));
}

public function services() { // get services
return json_decode($this->connect(array(
'key' => $this->api_key,
'action' => 'services',
)));
}

public function balance() { // get balance
return json_decode($this->connect(array(
'key' => $this->api_key,
'action' => 'balance',
)));
}


private function connect($post) {
$_post = Array();
if (is_array($post)) {
foreach ($post as $name => $value) {
$_post[] = $name.'='.urlencode($value);
}
}

$ch = curl_init($this->api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if (is_array($post)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
}
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
$result = curl_exec($ch);
if (curl_errno($ch) != 0 && empty($result)) {
$result = false;
}
curl_close($ch);
return $result;
}
}



Bu Api class'ını kullanarak diğer sitelere post gönderiyorsunuz. Sitenin belli API adresleri oluyor. Sipariş için order fonksiyonu, durum sorgulama için status fonksiyonu vs kullanılıyor. Smm apilerinin %95'i bu api tarzında kodlanmış şekilde.
Yukarıda siz başka siteye curl ile sipariş verebildiğiniz gibi sizinde bir api yolu belirleyim curl ile gelen veriler ile sipariş alabilmeniz lazım..




header('Content-Type: application/json');
include "api.php";
require_once '../sys/BasicDB.php';
require_once '../sys/function.php';

@@$apiKey = addslashes(strip_tags($_POST['key']));
@@$ApiYontemi = addslashes(strip_tags($_POST['action']));
@@$servisId = addslashes(strip_tags($_POST['service']));
@@$siparisUrl = addslashes(strip_tags($_POST['link']));
@@$yayinciId = addslashes(strip_tags($_POST['yayinci']));
@@$miktar = (intval($_POST['quantity']) > 0) ? addslashes(intval($_POST['quantity'])) : 0;
@@$siparisId = (intval($_POST['order']) > 0) ? addslashes(intval($_POST['order'])) : 0;

$json['error'] = 'yanlis yontem adi';

if ( $ApiYontemi == 'add' ) # Sipariş Ekleme
{
$kullaniciKontrol = $db->from('kullanicilar')
->where('ApiKey', $apiKey)
->all();
if (count($kullaniciKontrol) > 0)
{
$servisDetay = $db->from('servisler')
->where('Id', $servisId)
->all();

if ( count($servisDetay) > 0 ) {
$apiDetay = $db->from('api')
->where('Id', $servisDetay[0]['ApiId'])
->all();

$ozelFiyat = $db->from('ozelfiyat')
->where('KullaniciId', $kullaniciKontrol[0]['Id'])
->where('ServisId', $servisDetay[0]['Id'])
->all();
if (count($ozelFiyat) > 0) {
$fiyat = $ozelFiyat[0]['Fiyat'];
} else {
$fiyat = $servisDetay[0]['Fiyat'];
}

$tutar = (($miktar * $fiyat) / 1000);

if (($miktar <= 0) OR ($kullaniciKontrol[0]['Bakiye'] < $tutar)) {
$json['error'] = 'Bakiyeniz yeterli değil.';
} elseif ($miktar < $servisDetay[0]['Minimum']) {
$json['error'] = 'Siparişiniz minimum miktarının altında.';
} elseif ($miktar > $servisDetay[0]['Maximum']) {
$json['error'] = 'Siparişiniz maximum miktardan fazla.';
} else {

$api = new Api();
$api->api_url = $apiDetay[0]['ApiUrl'];
$api->api_key = $apiDetay[0]['ApiKey'];
if ($servisDetay[0]['ServisYontemi'] == "Paket"){
$siparis = $api->order(array("service" => $servisDetay[0]['ApiNo'], 'link' => $siparisUrl));
}elseif ($servisDetay[0]['ServisYontemi'] == "Servis"){
$siparis = $api->order(array("service" => $servisDetay[0]['ApiNo'], 'link' => $siparisUrl, 'quantity' => $miktar));
}

$siparis_id = $siparis->order;
if (count($siparis_id) > 0) {
$query = $db->insert('siparisler')
->set(array(
"SiparisId" => $siparis_id,
"ApiId" => $servisDetay[0]['ApiId'],
"ApiNo" => $servisDetay[0]['ApiNo'],
"ServisAdi" => $servisDetay[0]['ServisAdi'],
"Kalan" => $miktar,
"BaslangicSayisi" => 0,
"Yorum" => $yorum,
"Fiyat" => $tutar,
"ServisId" => $servisDetay[0]['Id'],
"Miktar" => $miktar,
"Link" => $siparisUrl,
"Durum" => 'Pending',
"Kullanici" => $kullaniciKontrol[0]['KullaniciAdi'],
"Yayinci" => $yayinciId,
"YayinciOdemesi" => 0,
));
}

$kullaniciBakiyesi = $kullaniciKontrol[0]['Bakiye'] - $tutar;
if ($query) {
$json['order']= $db->lastId();
unset($json['error']);
$update = $db->update('kullanicilar')
->where('Id', $kullaniciKontrol[0]['Id'])
->set([
'Bakiye' => $kullaniciBakiyesi
]);
}else{
$update = $db->update('servisler')
->where('Id', $servisDetay[0]['Id'])
->set([
'Durum' => "Pasif"
]);
}
}
}else{
$json['error'] = 'Servis Bulunamadi!';
}
}else{
$json['error'] = 'Kullanici Bulunamadi!';
}
}else if ( $ApiYontemi == 'status' ) # Sipariş Durumu
{
$kullaniciKontrol = $db->from('kullanicilar')
->where('ApiKey', $apiKey)
->all();
if (count($kullaniciKontrol) > 0)
{
$siparisKontrol = $db->from('siparisler')
->where('Id', $siparisId)
->where('Kullanici', $kullaniciKontrol[0]['KullaniciAdi'])
->all();
if ( count($siparisKontrol) > 0 )
{
$durum = $siparisKontrol[0]['Durum'];
$kalan = $siparisKontrol[0]['Kalan'];
$baslangicSayisi = $siparisKontrol[0]['BaslangicSayisi'];
$fiyat = $siparisKontrol[0]['Fiyat'];

if ($durum == 'Bekliyor'){
$durum = 'Pending';
} else if ($durum == 'İşlemde') {
$durum = 'Processing';
}else if ($durum == 'Devam Etmekte'){
$durum = 'In Processing';
}else if ($durum == 'Tamamlandı') {
$durum = 'Completed';
}else if ($durum == 'Kısmi Tamamlandı') {
$durum = 'Partial';
}else if ($durum == 'iptal edildi') {
$durum = 'Canceled';
}else if ($durum == 'Error') {
$durum = 'Hata';
}

$json['status'] = $durum;
$json['start_count'] = $baslangicSayisi;
$json['charge'] = $fiyat;
$json['remains'] = $kalan;
unset($json['error']);
} else {
$json['error'] = 'yanlış sipariş numarası';
}
} else {
$json['error'] = 'yanlış API anahtarı';
}
}else if ( $ApiYontemi == 'balance' ) # Sipariş Durumu
{
$kullaniciKontrol = $db->from('kullanicilar')
->where('ApiKey', $apiKey)
->all();

if (count($kullaniciKontrol) > 0)
{
$json['balance'] = $kullaniciKontrol[0]['Bakiye'];
unset($json['error']);
}else {
$json['error'] = 'yanlış API anahtarı';
}
}else if ( $ApiYontemi == 'services' ) # Servisler
{
$servisKontrol = $db->from('servisler')
->all();

if (count($servisKontrol) > 0)
{
foreach ($servisKontrol as $service) {
if ($service['ServisYontemi']) {
if ($service['ServisYontemi'] == "Servis") {
$service['ServisYontemi'] = "Default";
}elseif($service['ServisYontemi'] == "Paket"){
$service['ServisYontemi'] = "Package";
}elseif ($service['ServisYontemi'] == "Yorum" ) {
$service['ServisYontemi'] = "Custom Comments ";
}
}

$array[] = array(
'service' => $service['Id'],
'name' => $service['ServisAdi'],
'type' => $service['ServisYontemi'],
'rate' => $service['Fiyat'],
'min' => $service['Minimum'],
'max' => $service['Maximum'],
'category' => $service['KategoriAdi']
);
}
$json = $array;

unset($json['error']);
}else {
$json['error'] = 'Servis bulunamadı';
}
}else{
$json['error'] = 'yanlis yontem tipi';
}


$result = $json;
print_r(json_encode($result));
?>



gelen key ile kullanıcıyı ve servis id ile servisi buluyorsunuz. Servis bilgileri (Min,max,adet) ile fiyatı hesaplatıp kullanıcının bakiyesi ile kontrolleri sağlıyorsunuz.
Eğer sipariş girilmeye uygunsa siparişi girip dışarıya json ile dönüyorsunuz. Aynı şekilde gelen isteğe göre sipariş verme, sorgulama vs işlemleri yaptırmanız lazım..

Api kodunu çök önceden yazmışım temiz değil kendinize göre düzenlemeniz gerekir sadece mantığını anlayın diye bırakıyorum. Kolay gelsin.
TolgaYilmaz emulnurullah

kişi bu mesajı beğendi.

wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al