דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

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

דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי מנחם מענדל מענדי » 12:19 21/03/2018

דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

חוקר
הודעות: 496
הצטרף: 15:44 16/03/2016
מיקום: עיר התורה והחסידות ביתר עילית

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי חוקר » 22:11 21/03/2018

דחוף!
למה אצלך הכל דחוף?
תבקש לפני הדקה האחרונה!

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי boyoss » 22:17 21/03/2018

צריך למהר להביא את הגואל בזכות אהבת ישראל, אין זמן..

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי 011371 » 22:49 21/03/2018

כשאתה מוריד קובץ באמצעות הדוגמא ש"מאזין נלהב" צירף למחלקה ,
תוכן הקובץ מוחזר למשתנה a
ניתן לשמור אותו לערוך אותו להעלותו מחדש וכולי כמו כל מחרוזת טקסט שנמצא במשתנה

וגם להשים אותו בתוך הקובץ שהמחלקה ofile שמצורפת למחךקה הנ"ל יוצרת
ואז להעלותו שוב דרך המחלקה

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי מנחם מענדל מענדי » 12:50 22/03/2018

כשאתה מוריד קובץ באמצעות הדוגמא ש"מאזין נלהב" צירף למחלקה ,
תוכן הקובץ מוחזר למשתנה a
ניתן לשמור אותו לערוך אותו להעלותו מחדש וכולי כמו כל מחרוזת טקסט שנמצא במשתנה

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

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי רדיופון » 14:10 22/03/2018

כשאתה מוריד קובץ באמצעות הדוגמא ש"מאזין נלהב" צירף למחלקה ,
תוכן הקובץ מוחזר למשתנה a
ניתן לשמור אותו לערוך אותו להעלותו מחדש וכולי כמו כל מחרוזת טקסט שנמצא במשתנה

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

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

<?php


$DID = // מספר מערכת
$password = // סיסמת מערכת
$path1 = // מס' שלוחה
$A = //כאן לכתוב את ההגדרה שברצונך להוסיף לקיים, לדוגמא:
"password=1234
enter_id=yes"
;


$con = @new connecting_to_yemot_api($DID, $password);

if($result -> responseStatus != 'OK'){

$body = array
(
// נתיב הקובץ
'path' => "ivr/$path1/ext.ini",
);

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


// יצירת הקובץ
$File = new oFile('ext.ini', 'text/plain', "$a
$A");

$body = array
(
'path' => "ivr/$path1/ext.ini",
'convertAudio' => 0,
'fileUpload' => $File
);

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

print_r($b);
}

else{
print "id_list_message=t-";
echo "קרתה תקלה, נסה מאוחר יותר, ";
}

// print_r($a);

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
{
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;
}
}


?>

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי 011371 » 17:31 22/03/2018

כשאתה מוריד קובץ באמצעות הדוגמא ש"מאזין נלהב" צירף למחלקה ,
תוכן הקובץ מוחזר למשתנה a
ניתן לשמור אותו לערוך אותו להעלותו מחדש וכולי כמו כל מחרוזת טקסט שנמצא במשתנה

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

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

<?php


$DID = // מספר מערכת
$password = // סיסמת מערכת
$path1 = // מס' שלוחה
$A = //כאן לכתוב את ההגדרה שברצונך להוסיף לקיים, לדוגמא:
"password=1234
enter_id=yes"
;


$con = @new connecting_to_yemot_api($DID, $password);

if($result -> responseStatus != 'OK'){

$body = array
(
// נתיב הקובץ
'path' => "ivr/$path1/ext.ini",
);

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


// יצירת הקובץ
$File = new oFile('ext.ini', 'text/plain', "$a
$A");

$body = array
(
'path' => "ivr/$path1/ext.ini",
'convertAudio' => 0,
'fileUpload' => $File
);

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

print_r($b);
}

else{
print "id_list_message=t-";
echo "קרתה תקלה, נסה מאוחר יותר, ";
}

// print_r($a);

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
{
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;
}
}


?>
כל הכבוד על הסבלנות להכין כזו דוגמא מפורטת בימים כ"כ לחוצים של ערבי פסחים

רק הדוגמא

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

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

print_r($b);
משום מה לא הצלחתי להשתמש עם הפקודה print_r על מה שהמחלקה מחזירה בעת העלאת קובץ
לך זה עובד?

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי רדיופון » 17:43 22/03/2018

כל הכבוד על הסבלנות להכין כזו דוגמא מפורטת בימים כ"כ לחוצים של ערבי פסחים
זה היה מוכן לי מראש רק שיפצתי קצת... :)
רק הדוגמא

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

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

print_r($b);
משום מה לא הצלחתי להשתמש עם הפקודה print_r על מה שהמחלקה מחזירה בעת העלאת קובץ
לך זה עובד?
לי זה עובד מצוין.

זה התגובה שקיבלתי:

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

stdClass Object ( [responseStatus] => OK [path] => ivr/ext.ini [size] => 46 [yemotAPIVersion] => 6 )

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

Re: דחוף!איך במחלקה של מאזין נלהב אני יכול לערוך קובץ קיים ולא להעלות קובץ חדש שידרוס את הישן. תודה

שליחהעל ידי 011371 » 19:02 22/03/2018

תודה
הבנתי
הוא מחזיר אובייקט של גייסון ולא מערך רגיל


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

מי מחובר

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