├── .gitignore
├── LICENSE.md
├── README.md
├── composer.json
├── composer.lock
├── examples
└── index.php
└── src
├── Autoload.php
├── IvdException.php
├── IvdService.php
└── Request.php
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Mert Levent
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
💸 İnteraktif Vergi Dairesi
2 | https://ivd.gib.gov.tr
3 | Bu Paket ile GİB İnteraktif Vergi Dairesi üzerinden bazı şifresiz/şifreli işlemleri gerçekleştirebilirsiniz.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | ## Kurulum
14 |
15 | 🛠️ Paketi composer ile projenize dahil edin;
16 |
17 | ```bash
18 | composer require mlevent/ivd
19 | ```
20 |
21 | ## Örnek Kullanım
22 |
23 | ```php
24 | use Mlevent\Ivd\IvdService;
25 |
26 | // Şifresiz Giriş
27 | $ivd = (new IvdService)->login();
28 |
29 | // Vergi Numarası Doğrulama
30 | $result = $ivd->taxIdVerification(
31 | taxId : '1234567890',
32 | province : '016',
33 | taxOffice : '016252'
34 | );
35 |
36 | print_r($result);
37 | ```
38 |
39 | ### Gerçek Kullanıcı
40 |
41 | Kullanıcı bilgilerinizi `setCredentials` ya da `login` metoduyla tanımlayabilirsiniz.
42 |
43 | ```php
44 | use Mlevent\Ivd\IvdService;
45 |
46 | // Kullanıcı Bilgileriyle Giriş
47 | $ivd = (new IvdService)->login('TC Kimlik No', 'Parola');
48 | ```
49 |
50 | > Not: Token değerini herhangi bir yerde kullanmanız gerekmeyecek.
51 |
52 | ## Şifresiz İşlemler
53 |
54 | İnteraktif Vergi Dairesi üzerindeki bazı servisler şifresiz/giriş yapmadan kullanılabilir;
55 |
56 | ```php
57 | /**
58 | * Vergi Kimlik Numarası Sorgulama
59 | * Kimlik bilgileriyle Vergi Kimlik numarası sorgulama. Tüm alanların gönderilmesi zorunludur.
60 | *
61 | * @param string $name · İsim
62 | * @param string $lastName · Soyisim
63 | * @param string $fatherName · Baba Adı
64 | * @param string $province · İl
65 | * @param string $dateOfBirth · Doğum Tarihi
66 | * @return array
67 | */
68 | $ivd->taxIdInquiry(
69 | name : 'Mert',
70 | lastName : 'Levent',
71 | fatherName : 'Walter',
72 | province : '016',
73 | dateOfBirth : '19890511'
74 | );
75 |
76 | /**
77 | * Yabancılar İçin Vergi Kimlik Numarasından Sorgulama
78 | *
79 | * @param string $taxId · Vergi Numarası
80 | * @return array
81 | */
82 | $ivd->taxIdInquiryForForeigners(
83 | taxId : '1234567890'
84 | );
85 |
86 | /**
87 | * Vergi Kimlik Numarası Doğrulama
88 | * Sorgulanacak kişi ya da kurumun Vergi Kimlik ya da T.C. Kimlik numarasından sadece birini giriniz.
89 | *
90 | * @param string $taxId · Vergi Numarası
91 | * @param string $trId · TcKN
92 | * @param string $province · İl
93 | * @param string $taxOffice · Vergi Dairesi
94 | * @return array
95 | */
96 | $ivd->taxIdVerification(
97 | //taxId : '1234567890',
98 | trId : '11111111111',
99 | province : '016',
100 | taxOffice : '016252'
101 | );
102 |
103 | /**
104 | * Vergi Dairelerine ait liste çıktısını verir.
105 | *
106 | * @return array
107 | */
108 | $ivd->getTaxOffices();
109 |
110 | /**
111 | * Vergileri ve vergi kodlarına ait liste çıktısını verir.
112 | *
113 | * @return array
114 | */
115 | $ivd->getTaxList();
116 |
117 | /**
118 | * Ülkelere ait liste çıktısını verir.
119 | *
120 | * @return array
121 | */
122 | $ivd->getCountries();
123 |
124 | /**
125 | * Türkiye'deki illere ait liste çıktısını verir.
126 | *
127 | * @return array
128 | */
129 | $ivd->getProvinces();
130 |
131 | /**
132 | * Türkiye'deki iller ve ilçelere ait liste çıktısını verir.
133 | *
134 | * @return array
135 | */
136 | $ivd->getProvincesAndDistricts();
137 | ```
138 |
139 | ## Şifreli İşlemler
140 |
141 | İnteraktif Vergi Dairesinde kayıtlı TcKN ve şifre bilgileriyle oturum açılarak kullanılabilecek metodlar;
142 |
143 | ```php
144 | /**
145 | * Nüfus müdürlüğünde kayıtlı kimlik bilgileri.
146 | *
147 | * @return array
148 | */
149 | $ivd->getIdInformation();
150 |
151 | /**
152 | * Vergi dairesi ve nüfus müdürlüğü sicil kaydı.
153 | *
154 | * @return array
155 | */
156 | $ivd->getRegistry();
157 |
158 | /**
159 | * Şirketlerdeki ortaklık ve yöneticilik bilgileri.
160 | *
161 | * @return array
162 | */
163 | $ivd->getPartnerships();
164 |
165 | /**
166 | * Borç Durumu
167 | * Gelir İdaresi Başkanlığında kayıtlı borçlara ait liste çıktısını verir.
168 | *
169 | * @return array
170 | */
171 | $ivd->getDebtStatus();
172 |
173 | /**
174 | * KYK Borç Durumu
175 | *
176 | * @return array
177 | */
178 | $ivd->getKYKDebtStatus();
179 |
180 | /**
181 | * Banka Hesaplarına Uygulanan Elektronik Hacizler
182 | *
183 | * @return array
184 | */
185 | $ivd->getGarnishmentsAppliedToBankAccounts();
186 |
187 | /**
188 | * Araçlara Uygulanan Elektronik Hacizler
189 | *
190 | * @return array
191 | */
192 | $ivd->getGarnishmentsAppliedToVehicles();
193 |
194 | /**
195 | * Mevcut Araç Bilgileri
196 | * Şu an sahibi olduğunuz araçlara ait bilgileri döndürür.
197 | *
198 | * @return array
199 | */
200 | $ivd->getCurrentVehicles();
201 |
202 | /**
203 | * Geçmiş Araç Bilgileri
204 | * Geçmişte sahibi olduğunuz, artık üzerinize kayıtlı olmayan araçlara ait bilgileri döndürür.
205 | *
206 | * @return array
207 | */
208 | $ivd->getPreviousVehicles();
209 |
210 | /**
211 | * Vergi Ceza İhbarname Bilgileri
212 | *
213 | * @return array
214 | */
215 | $ivd->getTaxPenaltyNoticeInformation();
216 |
217 | /**
218 | * Sanal Pos Ödemeleri
219 | * Gelir İdaresi Başkanlığına sanal pos üzerinden yapılan ödemelerin listesini verir.
220 | *
221 | * @param int $year · Yıl
222 | * @return array
223 | */
224 | $ivd->getVirtualPosPayments(
225 | year: 2018
226 | );
227 |
228 | /**
229 | * E-Devlet Ödemeleri
230 | * Gelir İdaresi Başkanlığına e-devlet üzerinden yapılan ödemelerin listesini verir.
231 | *
232 | * @param int $year · Yıl
233 | * @return array
234 | */
235 | $ivd->getEDevletPayments(
236 | year: 2018
237 | );
238 |
239 | /**
240 | * Diğer Ödemeler
241 | *
242 | * @param int $year · Yıl
243 | * @return array
244 | */
245 | $ivd->getOtherPayments(
246 | year: 2018
247 | );
248 |
249 | /**
250 | * Servis Mesajları
251 | * İnteraktif Vergi Dairesi üzerinden yayınlanan servis mesajlarını döndürür.
252 | *
253 | * @return array
254 | */
255 | $ivd->getServiceMessages();
256 | ```
257 |
258 | ## 📧İletişim
259 |
260 | İletişim için ghergedan@gmail.com adresine e-posta gönderin.
261 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mlevent/ivd",
3 | "description": "İnternet Vergi Dairesi Yardımcı Aracı",
4 | "keywords": [
5 | "gib",
6 | "ivd",
7 | "interaktif vergi dairesi",
8 | "maliye",
9 | "vergi"
10 | ],
11 | "autoload": {
12 | "psr-4": {
13 | "Mlevent\\Ivd\\": "src/"
14 | }
15 | },
16 | "authors": [
17 | {
18 | "name": "mlevent",
19 | "email": "ghergedan@gmail.com"
20 | }
21 | ],
22 | "require": {
23 | "php": "^8.0"
24 | },
25 | "minimum-stability": "dev",
26 | "prefer-stable": true
27 | }
28 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "fa33f0ebf5560ded70cb0a89c65d29d9",
8 | "packages": [],
9 | "packages-dev": [],
10 | "aliases": [],
11 | "minimum-stability": "dev",
12 | "stability-flags": [],
13 | "prefer-stable": true,
14 | "prefer-lowest": false,
15 | "platform": {
16 | "php": "^8.0"
17 | },
18 | "platform-dev": [],
19 | "plugin-api-version": "2.3.0"
20 | }
21 |
--------------------------------------------------------------------------------
/examples/index.php:
--------------------------------------------------------------------------------
1 | login();
9 |
10 | var_dump($ivd->getTaxList());
11 |
12 | $ivd->logout();
13 |
14 | } catch(IvdException $e){
15 |
16 | print_r($e->getMessage());
17 | print_r($e->getResponse());
18 | print_r($e->getRequest());
19 | }
--------------------------------------------------------------------------------
/src/Autoload.php:
--------------------------------------------------------------------------------
1 | response = $response;
30 | $this->request = $request;
31 | }
32 |
33 | /**
34 | * getResponse
35 | *
36 | * @return mixed
37 | */
38 | public function getResponse(): mixed
39 | {
40 | return $this->response;
41 | }
42 |
43 | /**
44 | * hasResponse
45 | *
46 | * @return boolean
47 | */
48 | public function hasResponse(): bool
49 | {
50 | return $this->response !== null;
51 | }
52 |
53 | /**
54 | * getRequest
55 | *
56 | * @return mixed
57 | */
58 | public function getRequest(): mixed
59 | {
60 | return $this->request;
61 | }
62 | }
--------------------------------------------------------------------------------
/src/IvdService.php:
--------------------------------------------------------------------------------
1 | username = $username;
27 | $this->password = $password;
28 | return $this;
29 | }
30 |
31 | /**
32 | * getCredentials
33 | */
34 | public function getCredentials(): array
35 | {
36 | return ['username' => $this->username, 'password' => $this->password];
37 | }
38 |
39 | /**
40 | * setToken
41 | */
42 | public function setToken(string $token = null): self
43 | {
44 | $this->token = $token;
45 | return $this;
46 | }
47 |
48 | /**
49 | * getToken
50 | */
51 | public function getToken(): ?string
52 | {
53 | return $this->token;
54 | }
55 |
56 | /**
57 | * guestLogin
58 | */
59 | public function guestLogin(): self
60 | {
61 | $response = new Request(self::ApiAuth, [
62 | 'assoscmd' => 'cfsession',
63 | 'rtype' => 'json',
64 | 'fskey' => 'intvrg.fix.session',
65 | 'fuserid' => 'INTVRG_FIX',
66 | ]);
67 |
68 | $this->setToken($response->get('token'));
69 | return $this;
70 | }
71 |
72 | /**
73 | * login
74 | */
75 | public function login(string $username = null, string $password = null): self
76 | {
77 | if ($username && $password) {
78 | $this->setCredentials($username, $password);
79 | }
80 |
81 | if (!$this->username || !$this->password) {
82 | return $this->guestLogin();
83 | }
84 |
85 | $response = new Request(self::ApiAuth, [
86 | 'assoscmd' => 'multilogin',
87 | 'rtype' => 'json',
88 | 'userid' => $this->username,
89 | 'sifre' => $this->password,
90 | 'parola' => 'maliye',
91 | 'controlCaptcha' => 'false',
92 | 'dk' => '',
93 | 'imageID' => '',
94 | ]);
95 |
96 | $this->setToken($response->get('token'));
97 | return $this;
98 | }
99 |
100 | /**
101 | * logout
102 | */
103 | public function logout(): bool
104 | {
105 | $response = new Request(self::ApiDispatch,
106 | $this->setParams(['kullaniciBilgileriService_logout', 'PG_MAIN_DYNAMIC', 'cbf1b5447b6cc-44'])
107 | );
108 |
109 | $this->setCredentials();
110 | $this->setToken();
111 |
112 | return $response->object('data')->logout == 1;
113 | }
114 |
115 | /**
116 | * Vergi Numarası Sorgulama
117 | */
118 | public function taxIdInquiry(string $name, string $lastName, string $fatherName, string $province, string $dateOfBirth)
119 | {
120 | $response = new Request(self::ApiDispatch,
121 | $this->setParams(['vergiNoIslemleri_vergiNoSorgulaSorgu', 'P_INTVRG_INTVD_VKN_SORGULA_SORGU', '64864a0c5ef08-14'], [
122 | 'isim' => $name,
123 | 'soyisim' => $lastName,
124 | 'babaAdi' => $fatherName,
125 | 'il' => $province,
126 | 'dogumYili' => $dateOfBirth,
127 | ])
128 | );
129 | return $response->get('data');
130 | }
131 |
132 | /**
133 | * Yabancılar İçin Vergi Kimlik Numarasından Sorgulama
134 | */
135 | public function taxIdInquiryForForeigners(string $taxId)
136 | {
137 | $response = new Request(self::ApiDispatch,
138 | $this->setParams(['vergiNoService_yabanciVKNSorguSonuc', 'P_INTVRG_INTVD_YABANCI_VKN_SORGULA', '64864a0c5ef08-16'], [
139 | 'eVknWithValidationTx' => $taxId,
140 | ])
141 | );
142 | return $response->get('data');
143 | }
144 |
145 | /**
146 | * Vergi Kimlik Numarası Doğrulama
147 | */
148 | public function taxIdVerification(string $province, string $taxOffice, string $taxId = '', string $trId = '')
149 | {
150 | $response = new Request(self::ApiDispatch,
151 | $this->setParams(['vergiNoIslemleri_vergiNumarasiSorgulama', 'R_INTVRG_INTVD_VERGINO_DOGRULAMA', '64864a0c5ef08-15'], [
152 | 'dogrulama' => [
153 | 'vkn1' => $taxId,
154 | 'tckn1' => $trId,
155 | 'iller' => $province,
156 | 'vergidaireleri' => $taxOffice,
157 | ]
158 | ])
159 | );
160 | return $response->get('data');
161 | }
162 |
163 | /**
164 | * Sicil Kaydı
165 | */
166 | public function getRegistry()
167 | {
168 | $response = new Request(self::ApiDispatch,
169 | $this->setParams(['sicilIslemleri_evdoYsicilTckimliknoVknCevrimiMernisAdsoyad', 'RG_SICIL', '151218977cdcc-29'])
170 | );
171 | return $response->get('data');
172 | }
173 |
174 | /**
175 | * Kimlik Bilgileri
176 | */
177 | public function getIdInformation()
178 | {
179 | if ($registry = $this->getRegistry()) {
180 | return $registry['kimlikBilgileri'];
181 | }
182 | }
183 |
184 | /**
185 | * Şirketlerdeki Ortaklık ve Yöneticilik Bilgileri
186 | */
187 | public function getPartnerships()
188 | {
189 | $response = new Request(self::ApiDispatch,
190 | $this->setParams(['yoneticiOrtaklikIslemleri_sirketOrtaklikYoneticilikSorgula', 'P_MEVCUT_SIRKET_ORTAKLIK_YONETICILIK', '0861bf80b5f42-27'], [
191 | 'bilgi' => 1
192 | ])
193 | );
194 | return $response->get('data');
195 | }
196 |
197 | /**
198 | * Borç Durumu
199 | */
200 | public function getDebtStatus()
201 | {
202 | $response = new Request(self::ApiDispatch,
203 | $this->setParams(['tvdBorcIslemleri_borcGetirYeni', 'P_DASHBOARD', 'e95931c2f24ce-145'])
204 | );
205 | return $response->get('data');
206 | }
207 |
208 | /**
209 | * KYK Borç Durumu
210 | */
211 | public function getKYKDebtStatus()
212 | {
213 | $response = new Request(self::ApiDispatch,
214 | $this->setParams(['kykBorcDurum_borcDurumGetir', 'PG_KYK_BORC_DURUMU', 'cbf1b5447b6cc-32'])
215 | );
216 | return $response->get('data');
217 | }
218 |
219 | /**
220 | * Banka Hesaplarına Uygulanan Elektronik Hacizler
221 | */
222 | public function getGarnishmentsAppliedToBankAccounts()
223 | {
224 | $response = new Request(self::ApiDispatch,
225 | $this->setParams(['ehacizSorgulamaService_EhacizSorgulamaSonuc', 'P_INTVRG_INTVD_EHACIZ_ARAC_SRG', 'e95931c2f24ce-119'], [
226 | 'secim' => 2
227 | ])
228 | );
229 | return $response->get('data');
230 | }
231 |
232 | /**
233 | * Araçlara Uygulanan Elektronik Hacizler
234 | */
235 | public function getGarnishmentsAppliedToVehicles()
236 | {
237 | $response = new Request(self::ApiDispatch,
238 | $this->setParams(['ehacizSorgulamaService_EhacizSorgulamaSonuc', 'P_INTVRG_INTVD_EHACIZ_ARAC_SRG', 'e95931c2f24ce-146'], [
239 | 'secim' => 2
240 | ])
241 | );
242 | return $response->get('data');
243 | }
244 |
245 | /**
246 | * Mevcut Araç Bilgileri
247 | */
248 | public function getCurrentVehicles()
249 | {
250 | $response = new Request(self::ApiDispatch,
251 | $this->setParams(['aracBilgileriService_aracBilgileriGetir', 'P_MEVCUT_ARAC_BILGILERI', 'cbf1b5447b6cc-43'], [
252 | 'sorgulamaTip' => 1
253 | ])
254 | );
255 | return $response->get('data');
256 | }
257 |
258 | /**
259 | * Geçmiş Araç Bilgileri
260 | */
261 | public function getPreviousVehicles()
262 | {
263 | $response = new Request(self::ApiDispatch,
264 | $this->setParams(['aracBilgileriService_aracBilgileriGetir', 'P_GECMIS_ARAC_BILGILERI', '3be8a89c47b6c-31'], [
265 | 'sorgulamaTip' => 2
266 | ])
267 | );
268 | return $response->get('data');
269 | }
270 |
271 | /**
272 | * Vergi Ceza İhbarname Bilgileri
273 | */
274 | public function getTaxPenaltyNoticeInformation()
275 | {
276 | $response = new Request(self::ApiDispatch,
277 | $this->setParams(['cezaIhbarnameleriService_cezaIhbarnameleriGetir', 'P_CEZA_IHBARNAMELERI', '0861bf80b5f42-37'])
278 | );
279 | return $response->get('data');
280 | }
281 |
282 | /**
283 | * Sanal Pos Ödemeleri
284 | */
285 | public function getVirtualPosPayments(int $year)
286 | {
287 | $response = new Request(self::ApiDispatch,
288 | $this->setParams(['borcIslemleri_odemeSorgulaSpos', 'P_INTVRG_INTVD_ODEME_SORGULAMA', '0884d5a31205c-38'], [
289 | 'year' => $year
290 | ])
291 | );
292 | return $response->get('data');
293 | }
294 |
295 | /**
296 | * E-Devlet Ödemeleri
297 | */
298 | public function getEDevletPayments(int $year)
299 | {
300 | $response = new Request(self::ApiDispatch,
301 | $this->setParams(['tahsilatIslemleri_edevletOdemeleriSorgula', 'P_EDEVLET_ODEMELERIM', 'f3c28c5d3009f-35'], [
302 | 'tarih' => $year
303 | ])
304 | );
305 | return $response->get('data');
306 | }
307 |
308 | /**
309 | * Diğer Ödemeler
310 | */
311 | public function getOtherPayments(int $year)
312 | {
313 | $response = new Request(self::ApiDispatch,
314 | $this->setParams(['tahsilatIslemleri_mukellefeAitdemeleriSorgula', 'P_MUKELLEF_ODEME_SORGULAMA', '57a00a6bf5f92-38'], [
315 | 'yil' => $year
316 | ])
317 | );
318 | return $response->get('data');
319 | }
320 |
321 | /**
322 | * Servis Mesajları
323 | */
324 | public function getServiceMessages()
325 | {
326 | $response = new Request(self::ApiDispatch,
327 | $this->setParams(['kullaniciMesajlariService_kullaniciMesajlariGetir', 'PG_MAIN_DYNAMIC', 'e61d39920010c-61'])
328 | );
329 | return $response->get('data');
330 | }
331 |
332 | /**
333 | * __call
334 | */
335 | public function __call($name, $arguments)
336 | {
337 | $keysAndCommands = [
338 | 'getTaxOffices' => 'RF_VERGI_DAIRELERI',
339 | 'getTaxList' => 'RF_FILTRELI_VERGIKODLARI',
340 | 'getCountries' => 'RF_EVDO_ULKELER',
341 | 'getProvinces' => 'RF_INTVRG_INTVD_ILLER',
342 | 'getProvincesAndDistricts' => 'RF_SICIL_DOGUMYERI_ILILCELER',
343 | ];
344 |
345 | if (array_key_exists($name, $keysAndCommands)) {
346 | $response = new Request(self::ApiDispatch,
347 | $this->setParams(['referenceDataService_getCacheableRfDataInfo', 'undefined', 'e61d39920010c-56'], [
348 | 'status' => [['rf' => $keysAndCommands[$name]]]
349 | ])
350 | );
351 | return $response->get('data')[0]['values'];
352 | }
353 | }
354 |
355 | /**
356 | * setParams
357 | */
358 | public function setParams(array $command, array $payload = []): array
359 | {
360 | list($cmd, $pageName, $callId) = $command;
361 |
362 | return [
363 | 'callid' => $callId,
364 | 'cmd' => $cmd,
365 | 'pageName' => $pageName,
366 | 'token' => $this->token,
367 | 'jp' => json_encode($payload ?: (object) $payload),
368 | ];
369 | }
370 | }
--------------------------------------------------------------------------------
/src/Request.php:
--------------------------------------------------------------------------------
1 | 'application/json',
21 | 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
22 | ];
23 |
24 | /**
25 | * request
26 | *
27 | * @param string $url
28 | * @param array|null $parameters
29 | * @param boolean $post
30 | */
31 | public function __construct(string $url, ?array $parameters = null, bool $post = true)
32 | {
33 | $ch = curl_init();
34 | curl_setopt($ch, CURLOPT_URL, $url);
35 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
36 | curl_setopt($ch, CURLOPT_HEADER, false);
37 | curl_setopt($ch, CURLINFO_HEADER_OUT, true);
38 | curl_setopt($ch, CURLOPT_TIMEOUT, 20);
39 | curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
40 | curl_setopt($ch, CURLOPT_POST, true);
41 | curl_setopt($ch, CURLOPT_POST, 1);
42 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters));
43 | $response = json_decode(curl_exec($ch), true);
44 | $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
45 | curl_close($ch);
46 |
47 | if (!$response || isset($response['error']) || !empty($response['data']['hata'])) {
48 | throw new IvdException('İstek başarısız oldu.', $parameters, $response, $httpcode);
49 | }
50 | $this->response = $response;
51 | }
52 |
53 | /**
54 | * get
55 | */
56 | public function get(?string $element = null)
57 | {
58 | return is_null($element)
59 | ? $this->response
60 | : $this->response[$element];
61 | }
62 |
63 | /**
64 | * object
65 | */
66 | public function object(?string $element = null)
67 | {
68 | $response = json_decode(json_encode($this->response, JSON_FORCE_OBJECT), false);
69 |
70 | return is_null($element)
71 | ? $response
72 | : $response->$element;
73 | }
74 | }
--------------------------------------------------------------------------------