Skip to content

Instantly share code, notes, and snippets.

@y4kupkaya
Created September 20, 2023 20:16
Show Gist options
  • Save y4kupkaya/925b241bce4a578435f71be682b4c263 to your computer and use it in GitHub Desktop.
Save y4kupkaya/925b241bce4a578435f71be682b4c263 to your computer and use it in GitHub Desktop.
Example APU usage for medyamiz.com
<?php
class Api
{
/** API URL */
public $api_url = 'https://medyamiz.com/api/v2';
/** Your API key */
public $api_key = '';
/** Add order */
public function order($data)
{
$post = array_merge(['key' => $this->api_key, 'action' => 'add'], $data);
return json_decode($this->connect($post));
}
/** Get order status */
public function status($order_id)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'action' => 'status',
'order' => $order_id
])
);
}
/** Get orders status */
public function multiStatus($order_ids)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'action' => 'status',
'orders' => implode(",", (array)$order_ids)
])
);
}
/** Get services */
public function services()
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'action' => 'services',
])
);
}
/** Refill order */
public function refill(int $orderId)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'order' => $orderId,
])
);
}
/** Refill orders */
public function multiRefill(array $orderIds)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'orders' => implode(',', $orderIds),
]),
true,
);
}
/** Get refill status */
public function refillStatus(int $refillId)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'refill' => $refillId,
])
);
}
/** Get refill statuses */
public function multiRefillStatus(array $refillIds)
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'refills' => implode(',', $refillIds),
]),
true,
);
}
/** Get balance */
public function balance()
{
return json_decode(
$this->connect([
'key' => $this->api_key,
'action' => 'balance',
])
);
}
private function connect($post)
{
$_post = [];
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;
}
}
// Examples
$api = new Api();
$services = $api->services(); # Return all services
$balance = $api->balance(); # Return user balance
// Add order
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'runs' => 2, 'interval' => 5]); # Default
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'comments' => "good pic\ngreat photo\n:)\n;)"]); # Custom Comments
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'usernames' => "test, testing", 'hashtags' => "#goodphoto"]); # Mentions with Hashtags
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'usernames' => "test\nexample\nfb"]); # Mentions Custom List
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'hashtag' => "test"]); # Mentions Hashtag
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 1000, 'username' => "test"]); # Mentions User Followers
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 1000, 'media' => "http://medyamiz.com/p/Ds2kfEr24Dr"]); # Mentions Media Likers
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test']); # Package
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'runs' => 10, 'interval' => 60]); # Drip-feed
// Old posts only
$order = $api->order(['service' => 1, 'username' => 'username', 'min' => 100, 'max' => 110, 'posts' => 0, 'delay' => 30, 'expiry' => '11/11/2022']); # Subscriptions
// Unlimited new posts and 5 old posts
$order = $api->order(['service' => 1, 'username' => 'username', 'min' => 100, 'max' => 110, 'old_posts' => 5, 'delay' => 30, 'expiry' => '11/11/2022']); # Subscriptions
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'username' => "test"]); # Comment Likes
$order = $api->order(['service' => 1, 'link' => 'http://medyamiz.com/test', 'quantity' => 100, 'answer_number' => '7']); # Poll
$status = $api->status($order->order); # Return status, charge, remains, start count, currency
$statuses = $api->multiStatus([1, 2, 3]); # Return orders status, charge, remains, start count, currency
$refill = (array) $api->multiRefill([1, 2]);
$refillIds = array_column($refill, 'refill');
if ($refillIds) {
$refillStatuses = $api->multiRefillStatus($refillIds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment