-
-
Save hsyntnc/1780956d056347fbd773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Bulutfon Api | |
* Gelen Faxlar | |
*/ | |
include 'inc/config.php'; | |
function prepareFaxAttachment($path) { | |
$type = mime_content_type($path); | |
$basename = basename($path, pathinfo($path, PATHINFO_EXTENSION)); | |
$data = file_get_contents($path); | |
$base64 = 'data:'. $type . ';name:'. $basename .';base64:' . base64_encode($data); | |
return $base64; | |
} | |
// Fax gönderme işlemi öncesinde yüklenecek olan dosyayı sunucuya kopyalıyoruz. | |
if (@$_POST){ | |
$dir = 'files/'; | |
$file = $dir.basename($_FILES['file']['name']); | |
if (move_uploaded_file($_FILES['file']['tmp_name'],$file)){ | |
$file = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'].$file; | |
$file = prepareFaxAttachment($file); | |
} else { | |
die("Dosya aktarımı sırasında hata oluştu."); | |
} | |
$url = 'https://api.bulutfon.com/outgoing-faxes?access_token='.$token.'&title=Deneme&receivers=903623630000&did=902322290318&attachment=".$file'; | |
$curl = curl_init($url); | |
curl_setopt($curl,CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); | |
$curl_response = curl_exec($curl); | |
curl_close($curl); | |
$result = json_decode($curl_response, true); | |
var_dump($result); | |
die(); | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Fax Gönder</title> | |
<!-- Google Fonts --> | |
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900,700,600,300,200&subset=latin,latin-ext' rel='stylesheet' type='text/css'> | |
<!-- Main CSS --> | |
<link href="css/main.css" rel="stylesheet"> | |
<!-- Font CSS --> | |
<link href="css/fonts.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="title">Bulutfon Api Fax Gönderme</div> | |
<!-- Container --> | |
<div id="container"> | |
<form action="#" method="post" enctype="multipart/form-data"> | |
<input type="text" name="title" placeholder="Fax Başlığı"> | |
<small>Gönderilecek faxın başlığı.</small> | |
<input type="text" name="receivers" placeholder="Gönderilecek Numara"> | |
<small>Faxın gönderileceği numara.</small> | |
<input type="text" name="receivers" placeholder="Alıcılar"> | |
<small>Virgül (,) ile ayrılarak birden fazla alıcı girilebilir.</small> | |
<input type="file" name="file"> | |
<small>Göndermek istediğiniz dosyayı seçin.</small> | |
<button type="submit">Gönder <i class="flaticon-arrow487"></i></button> | |
</form> | |
</div> | |
<!-- Container Bitiş --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bu şekilde dener misin?
https://gist.github.com/hamitturkukaya/23a2d0d8c1a2b5153c2d