ctrl + r
1 |
<!--.*?--> |
replace all
işe yarar kod blokları
ctrl + r
1 |
<!--.*?--> |
replace all
1.Run git clone
2.Run composer install
3.Run cp .env.example .env
4.Run php artisan key:generate
5.Run php artisan migrate
6.Run php artisan serve
7.Go to link localhost:8000
merhabalar
elimizde bir çok faturanın listelendiği bir sayfa olsun. görüntüle diyince modal ile o pdf gösterilsin istiyoruz. base64 kodlarını da sayfaya doldurmak istemiyoruz. yapacağımız iş basit.
görüntüle butonuna onclick yazıp 1 değere faturanın modal idsi olacak. bu id, modal’ın bodysine yazdığın id. Unutma bunu. Onun yanında apiden base64 kodu almak için ya da neyse boşverin bunları.
ben size base64 kodunu pdfye dönüştüreyim sorunuz olursa iletirsiniz.
1 2 3 4 5 6 |
base = answer.base64x; var base = "base64kodu"; $("<iframe width='100%' height='100%' />") // create an iframe // add the source .attr('src', 'data:application/pdf;base64,' + base) .appendTo(viewid); |
viewid, id değeri verdiğiniz herhangi bir div olabilir.
An english support is available for this project. You can have an english support for this work. Thus, you may send an e-mail to info@alicancanpolat.com. I don’t have an excellent english but i think we’ll get along.
bu api ile bir hesaptan bir hesaba dolar, euro veya tl her ne isterseniz gönderebiliyorsunuz. bir nevi banka gibi oluyorsunuz.
nerede bir göt göt api var beni bulur. avrupada halı saha & jigola merkezi ödemesinde kullanılmak üzere wise.com üzerinden bir api yazmam gerekiyordu. bunu yaptık fakat canımız çıktı. şimdi sırayla anlatıyorum, anlamayabilirsiniz, anlamadığınız yerleri mutlaka sorunuz.
api token alıyoruz bir tane wise.comdan.
1.adım – hangi para biriminden hangisine atacağımızı bildiriyoruz.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
$url = "https://api.transferwise.com/v2/quotes"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Authorization: Bearer $api_token", "Content-Type: application/json", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = <<<DATA { "sourceCurrency": "USD", "targetCurrency": "USD", "sourceAmount": 10, "targetAmount": null, "profile": PROFILEID } DATA; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); |
1.adımdan aldığın quoteUuid değerini tut.
2.adım – göndereceğin kişinin banka hesabı yok ise oluştur, var ise zaten sana aynı sonucu döndürüyor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
$url = "https://api.transferwise.com/v1/accounts"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Authorization: Bearer $api_token", "Content-Type: application/json", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = <<<DATA { "profile": 26112760, "accountHolderName": "$name", "currency": "USD", "type": "aba", "details": { "legalType": "PRIVATE", "abartn": "", "accountNumber": "", "accountType": "", "address" : { "country": "US", "state": "AZ", "city": "New York", "postCode": "10025", "firstLine": "45 Sunflower Ave" } } } DATA; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); |
buradan yine ID değeri döndürecek. O senin bank_account_id değerin. bunu da yaz bi kenara
3.aşama
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$guid = (string) Str::uuid(); // https://www.uuidgenerator.net/api/guid create $url = "https://api.transferwise.com/v1/transfers"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Authorization: Bearer $api_token", "Content-Type: application/json", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = <<<DATA { "targetAccount": $bank_account_id, "quoteUuid": "$quoteUuid", "customerTransactionId": "$guid" } DATA; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); |
artık paramızı, birimini, hangi kişiye olduğunu sisteme tanıttık.
burası bok gibi. try için değil fakat eur, usd için çift taraflı doğrulama istiyor bunu nasıl yapacağız.
Strong Customer Authentication dedikleri bi olay var. private ve public.pem diye bir dosya oluşturuyorsun. openssl ile oluştur.
1 2 |
$ openssl genrsa -out private.pem 2048 $ openssl rsa -pubout -in private.pem -out public.pem |
https://github.com/robclark56/TransferWise_PHP_SimpleAPIclass/blob/master/README.md
public.pem ‘i api ayarları bölümünden yüklüyorsun. Private sende kalıyor. Şimdi son aşamayı iki defa gönderiyorsun.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$url = "https://api.transferwise.com/v1/transfers"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Authorization: Bearer $api_token", "Content-Type: application/json", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = <<<DATA { "targetAccount": $bank_account_id, "quoteUuid": "$quoteUuid", "customerTransactionId": "$guid" } DATA; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); |
transferi başlattın. son aşama kaldı, transferi kendi bakiyenden düşmek.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
$url = "https://api.transferwise.com/v3/profiles/26112760/transfers/$transfer_id/payments"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Authorization: Bearer $api_token", "Content-Type: application/json", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = <<<DATA { "type":"BALANCE" } DATA; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HEADER,true); $resp = curl_exec($curl); curl_close($curl); list($headers, $content) = explode("\r\n\r\n",$resp,2); $k = 0; foreach (explode("\r\n",$headers) as $hdr){ $search_result=strstr($hdr,"x-2fa-approval: "); if($search_result){ $ott = $hdr; $k = 1; } } $ott = str_replace("x-2fa-approval: ","",$ott); |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
HTTP/1.1 403 Forbidden Date: Fri, 03 Jan 2020 12:34:56 GMT Content-Type: application/json;charset=UTF-8 x-2fa-approval-result: REJECTED x-2fa-approval: be2f6579-9426-480b-9cb7-d8f1116cc8b9 ... { "timestamp": "2020-01-03T12:34:56.789+0000", "status": 403, "error": "Forbidden", "message": "You are forbidden to send this request", "path": "/v3/profiles/{profileId}/transfers/{transferId}/payments" } |
hemen header bölümüne bakıyorsun. Gördün mü bak x-2fa-approval diye bir değişken verdi sana. Bu telefonuna gönderilmiş sms gibi. Bunu sana ayarladım ott diye bir değişkende şu an o.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$url = "https://api.transferwise.com/v3/profiles/26112760/transfers/$transfer_id/payments"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $pkeyid = openssl_pkey_get_private("-----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKCAQEAtc9xJLHWeODKJv5z37tJLkzUHHCsdgTsfYzbmcv5kokkuT+D YWIhs2qPJdjY/9WE/E7tAsWMxnWe78GKKAy+3sh8mFI3E1YeC3f3Fpti2KKjVBaR 12TxZeGntD0BGUHZait0cvZT+zDcB1kQQWNUx8dShbEiWrbpVh MaYbMXQPhhIoaY8sjsUAKuqQQyGxl+SxR7r4v8+fZhJLqFQ7Hrua -----END RSA PRIVATE KEY-----"); openssl_sign($ott, $Xsignature, $pkeyid,OPENSSL_ALGO_SHA256); openssl_free_key($pkeyid); $Xsignature= base64_encode($Xsignature); $headers = array( "Content-Type: application/json", "Authorization: Bearer a17d5ea1-ba36-45d5-9dad-47341227ed5f", "x-2fa-approval: $ott", "X-Signature: $Xsignature", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = '{"type": "BALANCE"}'; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); |
artık çift aşamalı doğrulama da tamam. paramız gitti. bok gibi anlattım ama olsun anladınız. kaynak az zaten.
şimdi laravelde bir User::all(); yaptık ve belli bir biçimde veriler geldi. Bunu diziye çevirdiğimizde aynı şekil kullanamıyordum. Bunu çevirmenin yolunu kendi çapımda buldum. burada subject değişkenini önceden çekilmiş verileri içerir. $subject = User::all() gibi.
1 2 3 4 5 6 7 8 9 |
$newsubject = new Collection(); foreach ($subject as $s){ $newsubject->push((object)[ 'id' => $s->id ]); $i++; } $subject = $newsubject; |
bir api yaparken laravel üzerinde ilgili link üzerinden olmayan bir linke girildiğinde json olarak not found değeri geri döndürmesi için App\Exceptions\Handler.php içine girilmesi gereken kod;
1 2 3 4 5 6 7 8 9 |
if (strpos($request->getRequestUri(), '/api/', 0) === 0 && get_class($exception) === NotFoundHttpException::class) { return response()->json([ "status" => 'failure', "error" => 'Page not found', 'code' => 404, "data" => null ], 404); } |
size kaç adet olacağı, adress gideceği adres(anlaması çok güç olabilirdi), password para çekim şifresi, method ise trx mi erc mi olduğunu belli etmek için. şimdi para çekerken sms kaldıracaksın, çift doğrulama kaldıracaksın, bunlar olunca 1 gün bekleyeceksin, bi tane para çekme şifresi belirleyeceksin. ip engeli mutlaka koy götündeki donu da alırlar. sakat iş dikkatli abi.
method türleri
ERC20
tokens: method=erc20
TRC20
tokens: method=trx
SPL
tokens: method=sol
Omni
tokens: method=omni
BEP2
tokens: method=bep2
Binance Smart Chain
tokens: method=bsc
Fantom
tokens: method=ftm
Avax
tokens: method=avax
Matic
tokens: method=matic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
<?php // API keys. $keys = array( 'apiKey'=> '', 'secretKey'=> '' ); // Get current time * 1000 to make sure I get a timestamp in milliseconds. API asks for it this way. $timestamp = time() * 1000; // Base url for all api calls. $baseURL = 'https://ftx.com/api'; // Specified url endpoint. This comes after the baseUrl. $endPoint = '/wallet/withdrawals'; $specialParam = json_encode( [ "coin"=> "USDT", "size"=> 1, "address"=> "to wallet address", "password" => '18812', "method" => 'trx' ] ); // Data that should be added to the encryption of the keys. $signature = $timestamp . 'POST/api' . $endPoint . $specialParam; // Hashing the secret key. $secret = hash_hmac('sha256', $signature, $keys['secretKey']); // For account data $url = $baseURL . $endPoint; // Init session for CURL. $ch = curl_init(); // Options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $specialParam); // Init headers for access to the FTX API signed data. $headers = array(); // $headers[] = 'Content-type: application/x-www-form-urlencoded'; $headers[] = 'Accept: application/json'; $headers[] = 'Content-Type: application/json'; $headers[] = 'FTX-KEY: ' . $keys['apiKey']; $headers[] = 'FTX-SIGN: ' . $secret; $headers[] = 'FTX-TS: ' . $timestamp; // Setting headers curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Execute request. $result = curl_exec($ch); // Ends the CURL session, frees all resources and deletes the curl (ch). curl_close($ch); echo($result); ?> |
ftx api key bilginizi girerek bakiyenizi sorgulayabilirsiniz. öyle sınıf fonksiyon hepsinin amk. al direk temiz kullan. api key ve secret bilginizi girmeyi unutmayınız.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<?php // API keys. $keys = array( 'apiKey'=> '', 'secretKey'=> '' ); // Get current time * 1000 to make sure I get a timestamp in milliseconds. API asks for it this way. $timestamp = time() * 1000; // Base url for all api calls. $baseURL = 'https://ftx.com/api'; // Specified url endpoint. This comes after the baseUrl. $endPoint = '/wallet/balances'; // Data that should be added to the encryption of the keys. $signature = $timestamp . 'GET/api' . $endPoint; // Hashing the secret key. $secret = hash_hmac('sha256', $signature, $keys['secretKey']); // For account data $url = $baseURL . $endPoint; // Init session for CURL. $ch = curl_init(); // Options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Init headers for access to the FTX API signed data. $headers = array(); $headers[] = 'Accept: application/json'; $headers[] = 'Content-Type: application/json'; $headers[] = 'FTX-KEY: ' . $keys['apiKey']; $headers[] = 'FTX-SIGN: ' . $secret; $headers[] = 'FTX-TS: ' . $timestamp; // Setting headers curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Execute request. $result = curl_exec($ch); if (curl_errno($ch)) { echo(curl_error($ch)); exit(); } // Ends the CURL session, frees all resources and deletes the curl (ch). curl_close($ch); echo($result); ?> |
1 |
composer create-project laravel/laravel yourNameProject "8.*" |
sondaki yıldız o sürümün en son versiyonunu belirtir. örneğin 8.* yıldızın karşılığı yanlış hatırlamıyorsam 8.6. Laravel 9 sonrası ihtiyaç olabilir diye yazıvereyim dedim. yoksa heryerde yazıyor zaten
hemen login ve register controller oluşturuyoruz. login içine;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public function login(Request $request) { $request->validate([ 'email' => ['required', 'email'], 'password' => ['required'] ]); if (Auth::attempt($request->only('email', 'password'),true)){ return response()->json(Auth::user(), 200); } throw ValidationException::withMessages([ 'email' =>['The provided credentials are incorect.'] ]); } public function logout() { Auth::logout(); return redirect('/'); } |
register
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public function register(Request $request) { $request->validate([ 'name' => ['required'], 'email' => ['required', 'email', 'unique:users'], 'password' =>['required', 'min:6', 'confirmed'] ]); User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->password) ]); } |
api.php
1 2 3 4 5 6 7 |
Route::middleware('auth:sanctum')->get('/authenticated', function () { return true; }); Route::post('register', 'App\Http\Controllers\RegisterController@register'); Route::post('login', 'App\Http\Controllers\LoginController@login'); Route::post('logout', 'App\Http\Controllers\LoginController@logout')->name("logout"); |
routes.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
{ path: "/platform-users", name: "PlatformUsersIndex", component: PlatformUsersIndex, meta: { title: 'Platform Üyeleri', description:"Deneme", isLogin:true, isAdmin:true, }, }, { path: '/register', component: Register, meta: { title: 'Register', } }, { path: '/login', component: Login, name: 'Login', meta: { title: 'Login', } }, |
app.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
const router = new VueRouter({ mode: "history", routes: routes }); router.beforeEach((to, from, next) => { if(to.path == "/login" || to.path == "/register"){ axios.get('/api/authenticated').then(()=>{ return next({ name: 'PlatformUsersIndex'}) }).catch(()=>{ next() }) } if(to.meta.isLogin == true){ axios.get('/api/authenticated').then(()=>{ next() }).catch(()=>{ return next({ name: 'Login'}) }) } document.title = to.meta.title next(); }) const app = new Vue({ el: "#app", router: router }); |