מחלקה של תקשורת עם ימות API

011371
הודעות: 997
הצטרף: 23:33 07/12/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי 011371 » 15:47 07/02/2018

יפה מאד!
יש אפשרות לקבל את:
מספר המאזינים כעת
פירוט שיחות פעילות
פירוט שיחות
?
דרך ה yemot api זה לא קיים
מחכים שיפתחו
או שמישהו ידריך איך אפשר להתחבר לאתר אם אופציה של curl
(אולי אני לא יודע אבל יש דרך להשתמש ב file_get_contents כאשר צריך לשלוח חלק מהנתונים בPOST ?)
למיטב ידיעתי אפשרי, פירוט שיחות כללי (חודשי) לא.
שיחות פעילות ומספר המאזינים כן.
אתה יודע איך?

BY6199
הודעות: 1635
הצטרף: 13:11 08/01/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי BY6199 » 15:55 07/02/2018

דרך ה yemot api זה לא קיים
מחכים שיפתחו
או שמישהו ידריך איך אפשר להתחבר לאתר אם אופציה של curl
(אולי אני לא יודע אבל יש דרך להשתמש ב file_get_contents כאשר צריך לשלוח חלק מהנתונים בPOST ?)
למיטב ידיעתי אפשרי, פירוט שיחות כללי (חודשי) לא.
שיחות פעילות ומספר המאזינים כן.
אתה יודע איך?
תשאל את אחד המשתמשים הבאים
חוקר מאזין נלהב boyoss

boyoss
הודעות: 129
הצטרף: 11:29 03/04/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי boyoss » 16:15 07/02/2018

@957 אפשר בלי שום בעייה, אשל לך במייל בל"נ

957
הודעות: 31
הצטרף: 10:04 28/07/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי 957 » 16:26 07/02/2018

@957 אפשר בלי שום בעייה, אשל לך במייל בל"נ
תודה רבה
יש מקום מסודר עם תיעוד לכל הפונקציות או שצריך לקושש פה?

מנחם מענדל מענדי
הודעות: 980
הצטרף: 16:42 28/04/2016

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי מנחם מענדל מענדי » 20:43 19/04/2018

במחלקה הנ"ל, איך אני יכול להדפיס "סיסמא שגוייה" במקרה שהסיסמא או אחד מהנתונים שגוי.
תודה

רדיופון
הודעות: 601
הצטרף: 12:35 10/04/2016

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי רדיופון » 21:06 19/04/2018

במחלקה הנ"ל, איך אני יכול להדפיס "סיסמא שגוייה" במקרה שהסיסמא או אחד מהנתונים שגוי.
תודה
תחפש כאן:

קוד: בחירת הכל

class BodyPost
{
// part "multipart/form-data"
public static function PartPost($name, $val)
{
$body = 'Content-Disposition: form-data; name="' . $name . '"';
// check instance of oFile
if($val instanceof oFile)
{
$file = $val->Name();
$mime = $val->Mime();
$cont = $val->Content();

$body .= '; filename="' . $file . '"' . "\r\n";
$body .= 'Content-Type: ' . $mime ."\r\n\r\n";
$body .= $cont."\r\n";
} else $body .= "\r\n\r\n".$val."\r\n";
return $body;
}

public static function Get(array $post, $delimiter = '-------------0123456789')
{
if(is_array($post) && !empty($post))
{
$bool = true;
//foreach($post as $val) if($val instanceof oFile) {$bool = true; break; };
if($bool)
{
$ret = '';
foreach($post as $name=>$val)
$ret .= '--' . $delimiter. "\r\n". self::PartPost($name, $val);
$ret .= "--" . $delimiter . "--\r\n";
} else $ret = http_build_query($post);
} else throw new \Exception('Error input param!');
return $ret;
}
}

class oFile
{
private $name;
private $mime;
private $content;

public function __construct($name, $mime=null, $content=null)
{
if(is_null($content))
{
$info = pathinfo($name);
// check is exist and readable file
if(!empty($info['basename']) && is_readable($name))
{
$this->name = $info['basename'];
// get MIME
$this->mime = mime_content_type($name);
// load file
$content = file_get_contents($name);
if($content!==false)
{
$this->content = $content;
}
else
{
throw new Exception('Don`t get content - "'.$name.'"');
}
}
else
{
throw new Exception('Error param');
}
}
else
{
$this->name = $name;
if(is_null($mime)) $mime = mime_content_type($name);
$this->mime = $mime;
$this->content = $content;
};
}

public function Name() { return $this->name; }

public function Mime() { return $this->mime; }

public function Content() { return $this->content; }

}

class connecting_to_yemot_api
{
public $token;

const URL = 'https://www.call2all.co.il/ym/api/';

public function __construct($user_name, $password)
{
$body = array('username' => $user_name, 'password' => $password);

$body = http_build_query($body);

$opts = array('http' => array(

'method' => 'POST',

'header' => "Content-Type: application/x-www-form-urlencoded",

'content' => $body,

'follow_location' => false) );

$context = stream_context_create($opts);

$url = self::URL.'Login';

$result = file_get_contents($url, FALSE, $context);

$result = json_decode($result);

if($result -> responseStatus == 'OK')
{
$this -> token = $result -> token;

return TRUE;
}
else
{
// להדפיס כאן באם אחד מהנתונים שגוי
print "id_list_message=t-";
echo 'שם המשתמש או הסיסמא של המערכת שגויים';
throw new Exception('שם המשתמש או הסיסמא של המערכת שגויים');
}
}

public function __destruct()
{
$this -> connecting('Logout');
}

public function connecting($action, $body = array())
{
$delimiter = '----'.uniqid();

$body['token'] = $this -> token;

$body = BodyPost::Get($body, $delimiter);

$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data; boundary='.$delimiter,
'content' => $body,
'follow_location' => false
)
);
$context = stream_context_create($opts);

$url = self::URL.$action;

$result = file_get_contents($url, FALSE, $context);

$headers = $this -> parseHeaders($http_response_header);

if($headers['Content-Type'][0] == 'application/json')
{
return json_decode($result);
}
else
{
return $result;
}
}

private function parseHeaders($headers)
{
// פונקציה שמקבלת מערך של שורות הכותרות
// הפונקציה מפרקת את קבצי הקוקי לתת-מערך נפרד


// מערך הכותרות
$head = array();

foreach( $headers as $k=>$v )
{
$t = explode( ':', $v, 2 );

if( isset( $t[1] ) )
{
if($t[0] == 'Set-Cookie')
{
$CookiesArr = array();

$cookies = explode( ';', $t[1]);

foreach($cookies as $cookie)
{
$c = explode( '=', $cookie);

if( isset( $c[1] ) )
{
$CookiesArr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$CookiesArr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $CookiesArr;
}
elseif($t[0] == 'Content-Type')
{
$arr = array();

$children = explode( ';', $t[1]);

foreach($children as $child)
{
$c = explode( '=', $child);

if( isset( $c[1] ) )
{
$arr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$arr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $arr;
}
else
{
$head[ trim($t[0]) ] = trim( $t[1] );
}
}
else
{
$head[] = $v;
if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) )
{
$head['reponse_code'] = intval($out[1]);
}
}
}
return $head;
}
}

מנחם מענדל מענדי
הודעות: 980
הצטרף: 16:42 28/04/2016

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי מנחם מענדל מענדי » 07:11 20/04/2018

ממש תודה אבל עוד שאלה.
איך אני יכול להעלות באמצעות המחלקה הנ"ל קובץ שמע בhtml באפשרות "בחר קובץ"?
תודה

011371
הודעות: 997
הצטרף: 23:33 07/12/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי 011371 » 08:16 20/04/2018

ממש תודה אבל עוד שאלה.
איך אני יכול להעלות באמצעות המחלקה הנ"ל קובץ שמע בhtml באפשרות "בחר קובץ"?
תודה

קוד: בחירת הכל

<?php


$DID = '0773137770' ;
$PASS = '1234' ;
$path = 'ivr/M1000.wav' ;



$con = new connecting_to_yemot_api( $DID , $PASS );

//העלאת הקובץ לשידור
$feMessage='';
if($_POST['submit']=='העלה'){
//בדיקה האם הקובץ קיים
if($_FILES['uploadedfile']['size']==0)
{$feMessage="<FONT color='red'>לא נבחר קובץ!, אנא בחר קובץ ונסה שנית</FONT><br />";}
//בדיקה האם אירעה שגיאה בהעלאה
else{if($_FILES[uploadedfile][error] !=0)
{$feMessage="<FONT color='red'>אירעה שגיאה במהלך העלאת הקובץ!, אנא בחר קובץ ונסה שנית</FONT><br />";}
else{

// יצירת הקובץ
$File = new oFile('ext.ini', 'text/plain',
file_get_contents($_FILES[uploadedfile][tmp_name]));

$body = array
(
'path' => $path ,
'convertAudio' => 1,
'fileUpload' => $File
);

$a = $con -> connecting('UploadFile', $body);

//אם הצליח
if($a -> responseStatus == OK)
{



$feMessage="<FONT color='green'>הקובץ: <b><u>".$_FILES['uploadedfile']['name']."</u></b>, הועלה בהצלחה! </FONT><br />";
}

else
{
$feMessage="<FONT color='red'>אירעה שגיאה במהלך העלאת הקובץ: <b><u>".$_FILES['uploadedfile']['name']."</u></b>, נסה שוב! </FONT><br />";
}
}}

}

//טופס העלאת הודעה לשידור
$uploab_form=
'<FORM method="post" enctype="multipart/form-data" >'

. $feMessage .

'<p>
<aside>העלאת הודעה חדשה : </aside>
<input name="uploadedfile" type="file" />
</p>
<p>
<INPUT TYPE="SUBMIT"
NAME="submit" VALUE="העלה" />
</p>
</FORM>';

print $uploab_form;



//===============המחלקה=============//



class BodyPost
{
// part "multipart/form-data"
public static function PartPost($name, $val)
{
$body = 'Content-Disposition: form-data; name="' . $name . '"';
// check instance of oFile
if($val instanceof oFile)
{
$file = $val->Name();
$mime = $val->Mime();
$cont = $val->Content();

$body .= '; filename="' . $file . '"' . "\r\n";
$body .= 'Content-Type: ' . $mime ."\r\n\r\n";
$body .= $cont."\r\n";
} else $body .= "\r\n\r\n".$val."\r\n";
return $body;
}

public static function Get(array $post, $delimiter = '-------------0123456789')
{
if(is_array($post) && !empty($post))
{
$bool = true;
//foreach($post as $val) if($val instanceof oFile) {$bool = true; break; };
if($bool)
{
$ret = '';
foreach($post as $name=>$val)
$ret .= '--' . $delimiter. "\r\n". self::PartPost($name, $val);
$ret .= "--" . $delimiter . "--\r\n";
} else $ret = http_build_query($post);
} else throw new \Exception('Error input param!');
return $ret;
}
}

class oFile
{
private $name;
private $mime;
private $content;

public function __construct($name, $mime=null, $content=null)
{
if(is_null($content))
{
$info = pathinfo($name);
// check is exist and readable file
if(!empty($info['basename']) && is_readable($name))
{
$this->name = $info['basename'];
// get MIME
$this->mime = mime_content_type($name);
// load file
$content = file_get_contents($name);
if($content!==false)
{
$this->content = $content;
}
else
{
throw new Exception('Don`t get content - "'.$name.'"');
}
}
else
{
throw new Exception('Error param');
}
}
else
{
$this->name = $name;
if(is_null($mime)) $mime = mime_content_type($name);
$this->mime = $mime;
$this->content = $content;
};
}

public function Name() { return $this->name; }

public function Mime() { return $this->mime; }

public function Content() { return $this->content; }

}

class connecting_to_yemot_api
{
public $token;

const URL = 'https://www.call2all.co.il/ym/api/';

public function __construct($user_name, $password)
{
$body = array('username' => $user_name, 'password' => $password);

$body = http_build_query($body);

$opts = array('http' => array(

'method' => 'POST',

'header' => "Content-Type: application/x-www-form-urlencoded",

'content' => $body,

'follow_location' => false) );

$context = stream_context_create($opts);

$url = self::URL.'Login';

$result = file_get_contents($url, FALSE, $context);

$result = json_decode($result);

if($result -> responseStatus == 'OK')
{
$this -> token = $result -> token;

return TRUE;
}
else
{
throw new Exception('שם המשתמש או הסיסמא של המערכת שגויים');
}
}

public function __destruct()
{
$this -> connecting('Logout');
}

public function connecting($action, $body = array())
{
$delimiter = '----'.uniqid();

$body['token'] = $this -> token;

$body = BodyPost::Get($body, $delimiter);

$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data; boundary='.$delimiter,
'content' => $body,
'follow_location' => false
)
);
$context = stream_context_create($opts);

$url = self::URL.$action;

$result = file_get_contents($url, FALSE, $context);

$headers = $this -> parseHeaders($http_response_header);

if($headers['Content-Type'][0] == 'application/json')
{
return json_decode($result);
}
else
{
return $result;
}
}

private function parseHeaders($headers)
{
// פונקציה שמקבלת מערך של שורות הכותרות
// הפונקציה מפרקת את קבצי הקוקי לתת-מערך נפרד


// מערך הכותרות
$head = array();

foreach( $headers as $k=>$v )
{
$t = explode( ':', $v, 2 );

if( isset( $t[1] ) )
{
if($t[0] == 'Set-Cookie')
{
$CookiesArr = array();

$cookies = explode( ';', $t[1]);

foreach($cookies as $cookie)
{
$c = explode( '=', $cookie);

if( isset( $c[1] ) )
{
$CookiesArr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$CookiesArr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $CookiesArr;
}
elseif($t[0] == 'Content-Type')
{
$arr = array();

$children = explode( ';', $t[1]);

foreach($children as $child)
{
$c = explode( '=', $child);

if( isset( $c[1] ) )
{
$arr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$arr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $arr;
}
else
{
$head[ trim($t[0]) ] = trim( $t[1] );
}
}
else
{
$head[] = $v;
if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) )
{
$head['reponse_code'] = intval($out[1]);
}
}
}
return $head;
}
}


?>

מנחם מענדל מענדי
הודעות: 980
הצטרף: 16:42 28/04/2016

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי מנחם מענדל מענדי » 12:39 23/04/2018

ממש תודה אבל עוד שאלה.
איך אני יכול להעלות באמצעות המחלקה הנ"ל קובץ שמע בhtml באפשרות "בחר קובץ"?
תודה

קוד: בחירת הכל

<?php


$DID = '0773137770' ;
$PASS = '1234' ;
$path = 'ivr/M1000.wav' ;



$con = new connecting_to_yemot_api( $DID , $PASS );

//העלאת הקובץ לשידור
$feMessage='';
if($_POST['submit']=='העלה'){
//בדיקה האם הקובץ קיים
if($_FILES['uploadedfile']['size']==0)
{$feMessage="<FONT color='red'>לא נבחר קובץ!, אנא בחר קובץ ונסה שנית</FONT><br />";}
//בדיקה האם אירעה שגיאה בהעלאה
else{if($_FILES[uploadedfile][error] !=0)
{$feMessage="<FONT color='red'>אירעה שגיאה במהלך העלאת הקובץ!, אנא בחר קובץ ונסה שנית</FONT><br />";}
else{

// יצירת הקובץ
$File = new oFile('ext.ini', 'text/plain',
file_get_contents($_FILES[uploadedfile][tmp_name]));

$body = array
(
'path' => $path ,
'convertAudio' => 1,
'fileUpload' => $File
);

$a = $con -> connecting('UploadFile', $body);

//אם הצליח
if($a -> responseStatus == OK)
{



$feMessage="<FONT color='green'>הקובץ: <b><u>".$_FILES['uploadedfile']['name']."</u></b>, הועלה בהצלחה! </FONT><br />";
}

else
{
$feMessage="<FONT color='red'>אירעה שגיאה במהלך העלאת הקובץ: <b><u>".$_FILES['uploadedfile']['name']."</u></b>, נסה שוב! </FONT><br />";
}
}}

}

//טופס העלאת הודעה לשידור
$uploab_form=
'<FORM method="post" enctype="multipart/form-data" >'

. $feMessage .

'<p>
<aside>העלאת הודעה חדשה : </aside>
<input name="uploadedfile" type="file" />
</p>
<p>
<INPUT TYPE="SUBMIT"
NAME="submit" VALUE="העלה" />
</p>
</FORM>';

print $uploab_form;



//===============המחלקה=============//



class BodyPost
{
// part "multipart/form-data"
public static function PartPost($name, $val)
{
$body = 'Content-Disposition: form-data; name="' . $name . '"';
// check instance of oFile
if($val instanceof oFile)
{
$file = $val->Name();
$mime = $val->Mime();
$cont = $val->Content();

$body .= '; filename="' . $file . '"' . "\r\n";
$body .= 'Content-Type: ' . $mime ."\r\n\r\n";
$body .= $cont."\r\n";
} else $body .= "\r\n\r\n".$val."\r\n";
return $body;
}

public static function Get(array $post, $delimiter = '-------------0123456789')
{
if(is_array($post) && !empty($post))
{
$bool = true;
//foreach($post as $val) if($val instanceof oFile) {$bool = true; break; };
if($bool)
{
$ret = '';
foreach($post as $name=>$val)
$ret .= '--' . $delimiter. "\r\n". self::PartPost($name, $val);
$ret .= "--" . $delimiter . "--\r\n";
} else $ret = http_build_query($post);
} else throw new \Exception('Error input param!');
return $ret;
}
}

class oFile
{
private $name;
private $mime;
private $content;

public function __construct($name, $mime=null, $content=null)
{
if(is_null($content))
{
$info = pathinfo($name);
// check is exist and readable file
if(!empty($info['basename']) && is_readable($name))
{
$this->name = $info['basename'];
// get MIME
$this->mime = mime_content_type($name);
// load file
$content = file_get_contents($name);
if($content!==false)
{
$this->content = $content;
}
else
{
throw new Exception('Don`t get content - "'.$name.'"');
}
}
else
{
throw new Exception('Error param');
}
}
else
{
$this->name = $name;
if(is_null($mime)) $mime = mime_content_type($name);
$this->mime = $mime;
$this->content = $content;
};
}

public function Name() { return $this->name; }

public function Mime() { return $this->mime; }

public function Content() { return $this->content; }

}

class connecting_to_yemot_api
{
public $token;

const URL = 'https://www.call2all.co.il/ym/api/';

public function __construct($user_name, $password)
{
$body = array('username' => $user_name, 'password' => $password);

$body = http_build_query($body);

$opts = array('http' => array(

'method' => 'POST',

'header' => "Content-Type: application/x-www-form-urlencoded",

'content' => $body,

'follow_location' => false) );

$context = stream_context_create($opts);

$url = self::URL.'Login';

$result = file_get_contents($url, FALSE, $context);

$result = json_decode($result);

if($result -> responseStatus == 'OK')
{
$this -> token = $result -> token;

return TRUE;
}
else
{
throw new Exception('שם המשתמש או הסיסמא של המערכת שגויים');
}
}

public function __destruct()
{
$this -> connecting('Logout');
}

public function connecting($action, $body = array())
{
$delimiter = '----'.uniqid();

$body['token'] = $this -> token;

$body = BodyPost::Get($body, $delimiter);

$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data; boundary='.$delimiter,
'content' => $body,
'follow_location' => false
)
);
$context = stream_context_create($opts);

$url = self::URL.$action;

$result = file_get_contents($url, FALSE, $context);

$headers = $this -> parseHeaders($http_response_header);

if($headers['Content-Type'][0] == 'application/json')
{
return json_decode($result);
}
else
{
return $result;
}
}

private function parseHeaders($headers)
{
// פונקציה שמקבלת מערך של שורות הכותרות
// הפונקציה מפרקת את קבצי הקוקי לתת-מערך נפרד


// מערך הכותרות
$head = array();

foreach( $headers as $k=>$v )
{
$t = explode( ':', $v, 2 );

if( isset( $t[1] ) )
{
if($t[0] == 'Set-Cookie')
{
$CookiesArr = array();

$cookies = explode( ';', $t[1]);

foreach($cookies as $cookie)
{
$c = explode( '=', $cookie);

if( isset( $c[1] ) )
{
$CookiesArr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$CookiesArr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $CookiesArr;
}
elseif($t[0] == 'Content-Type')
{
$arr = array();

$children = explode( ';', $t[1]);

foreach($children as $child)
{
$c = explode( '=', $child);

if( isset( $c[1] ) )
{
$arr[ trim($c[0]) ] = trim( $c[1] );
}
else
{
$arr[] = trim( $c[0] );
}
}

$head[ trim($t[0]) ] = $arr;
}
else
{
$head[ trim($t[0]) ] = trim( $t[1] );
}
}
else
{
$head[] = $v;
if( preg_match( "#HTTP/[0-9\.]+\s+([0-9]+)#",$v, $out ) )
{
$head['reponse_code'] = intval($out[1]);
}
}
}
return $head;
}
}


?>
ממש תודה על כל העזרה, אבל עוד שאלה קטנה.
איך בהעלאת קבצי שמע למערכת לשלוחות השמעות קבצים שיעלה את הקובץ לפי המספר הסידורי במדרג עולה כמו בהעלאה רגילה דרך האתר הניהול הרגיל.
תודה

011371
הודעות: 997
הצטרף: 23:33 07/12/2017

Re: מחלקה של תקשורת עם ימות API

שליחהעל ידי 011371 » 13:17 23/04/2018



איך בהעלאת קבצי שמע למערכת לשלוחות השמעות קבצים שיעלה את הקובץ לפי המספר הסידורי במדרג עולה כמו בהעלאה רגילה דרך האתר הניהול הרגיל.
תודה
דרך הapi זה עדיין לא קיים

אולי ל"אהבת ישראל" יש קשרים עם ימות המשיח ויצליחו לשכנע אותם להוסיף אפשרות בAPI שכאשר הנתיב המשודר מסתיים ב "/" (סלש) ולא בשם קובץ יקבל הקובץ שם אוטומטי לפי המקובל באתר בתוך התיקייה הנ"ל

בינתיים צריך לחפש פתרון אחר
תוכל למשל לרשום בDB את מספר הקובץ האחרון שהעלית ולהוסיף 1 כל פעם.


חזור אל “פורום מפתחים API”

מי מחובר

משתמשים הגולשים בפורום זה: אין משתמשים רשומים | 0 אורחים