A PHP Error was encountered

Severity: Warning

Message: session_start(): open(/var/cpanel/php/sessions/ea-php56/sess_c09827f24bd3e628153559e94c07f9ad, O_RDWR) failed: No such file or directory (2)

Filename: libraries/Ewsec.php

Line Number: 168

Backtrace:

File: /home/bily/public_html/application/libraries/Ewsec.php
Line: 168
Function: session_start

File: /home/bily/public_html/application/controllers/Page.php
Line: 11
Function: is_logged_in

File: /home/bily/public_html/index.php
Line: 316
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php56)

Filename: libraries/Ewsec.php

Line Number: 168

Backtrace:

File: /home/bily/public_html/application/libraries/Ewsec.php
Line: 168
Function: session_start

File: /home/bily/public_html/application/controllers/Page.php
Line: 11
Function: is_logged_in

File: /home/bily/public_html/index.php
Line: 316
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Cannot start session when headers already sent

Filename: libraries/Ewsec.php

Line Number: 168

Backtrace:

File: /home/bily/public_html/application/libraries/Ewsec.php
Line: 168
Function: session_start

File: /home/bily/public_html/application/views/template/material/main.php
Line: 5
Function: is_logged_in

File: /home/bily/public_html/application/controllers/Page.php
Line: 33
Function: view

File: /home/bily/public_html/index.php
Line: 316
Function: require_once

کوتاه کننده لینک Bily.ir

لطفا کمی صبر کنید...

وب سرویس(API) کوتاه کننده لینک

اگر توسعه دهنده نرم افزار، سایت و یا اپلیکیشن هستید و به نوعی با لینک های گوناگون سروکار دارید، پیشنهاد می کنیم آن ها را کوتاه کنید تا حسابی جمع و جور و منسجم باشند. API کوتاه کننده لینک bily.ir بسیار ساده و کاربردی است. نمونه ی jQuery و PHP آن را می توانید در همین صفحه ببینید.
برای دریافت کلید TOKEN مخصوص خود، در پنل کاربری تان یک پروژه جدید بسازید یا صفحه مدیریت پروژه ها وارد شوید.

jQuery Sample

 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
var SYSURL='https://bily.ir/api/';
var SYSTOKEN='TOKEN';
function bily(url, hash='' )
{
  /*AJAX post request*/
  var posting = $.post( SYSURL+'shorten/'+$.now(), { url:url,hash: hash,token:SYSTOKEN } );

  posting.done(function( data ) {

    /*parse response*/
    var obj = JSON.parse(data);

    /*response parse check*/
    if(obj)
    {
      /*response validation*/
      if(obj.ok)
      {
        /*use shorted link*/
        alert(obj.short_link);
      }
      else
      {
        /*show error*/
        alert(obj.error);
      }
    }
  });

/*Test it!*/
bily("https://eastweb.ir/");

PHP Sample

 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
class Bily
{
	private $bily_api = 'https://bily.ir/api/shorten/';
	private $bily_token = 'TOKEN';

	public function __construct($token = '')
	{
		if ($token != '')
			$this->bily_token = $token;
	}

	private function send_post_request($url, $params)
	{
		$post = http_build_query($params);
		$curl = curl_init($url);
		curl_setopt_array($curl, array(
			CURLOPT_SSL_VERIFYPEER => 0,
			CURLOPT_SSL_VERIFYHOST => 0,
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_POST => 1,
			CURLOPT_POSTFIELDS => $post
		));

		$response = curl_exec($curl);
		curl_close($curl);
		return $response;
	}

	public function shorten($url,$suggest_hash='')
	{
		$params = array(
			'token' => $this->bily_token,
			'url' => $url,
			'hash'=>$suggest_hash
		);
		if ($shorten_data = $this->send_post_request($this->bily_api, $params))
			if ($json = json_decode($shorten_data, true))
				if ($json['ok'])
					return $json['short_link'];
		return $url;
	}
}
$bily=new Bily('TOKEN');
var_dump($bily->shorten('https://eastweb.ir'));