<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \App\Rules\Count;

class IvshopController extends Controller
{
    public function ubai(Request $request){
        
        if($request->quantity == null || $request->link == null){
            return('Bad Request');
        }else{
            
                $api = 'https://followers-gratis.com/api.php';
                
            
                $key = '2019gantidiaivanbangsatbocahtolol';
            
        
            $postdata = 'api='.$key.'&action=add&link='.request()->link.'&type='.request()->types.'&quantity='.request()->quantity;
            
            $ch = curl_init($api);
    		
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        		
        		
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
        
    		
    		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
            $result = curl_exec($ch);
            if (curl_errno($ch)) {
                $result = curl_error($ch);
            }
    				
            curl_close($ch);
            
            
            
            $order = json_encode($result);
            
            $ambil=	json_decode($result,true);
            
            
        }
        
        // if(isset($ambil['info']['order']['order_id']))
        // {
            
        // }
    }
}