איפוס רשימת תפוצה

AG הפקות
הודעות: 79
הצטרף: 19:36 11/03/2018

איפוס רשימת תפוצה

שליחהעל ידי AG הפקות » 00:03 08/04/2018

שלום לכל המפתחים
ושבוע טוב

אני מעוניין להריץ בצורה אוטומטית קובץ שמאפס רשימת תפוצה מסוימת בקו

הבעיה שלא הצלחתי לכתוב קובץ PHP שמאפס רשימת תפוצה

אשמח אם אחד מהמפתחים יעלה לפה את הקוד המלא שצריך לעלות לשרת ולעריץ כל שבוע כדי לאפס את רשימת התפוצה

תודה רבה
נאור

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

Re: איפוס רשימת תפוצה

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

בבקשה...

הערה: תבנית רשימת התפוצה צריכה להיות מספר מזהה של ימות ולא מספר סידורי. ראה כאן

בניתי את הקוד על המחלקה של "מאזין נלהב"

דרך אגב, אתה יכול להריץ את הקובץ אוטומטי ע"י האתר הזה

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

<?php

$DID = "0773137770"; // הכנס כאן מספר מערכת
$password = "1234"; // הכנס כאן סיסמת מערכת

$templateId = "123456"; //הכנס כאן את מספר תבנית רשמית התפוצה


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


$body = array
(
// מספר הקמפיין
'templateId' => $templateId,
);

$a = @$con -> connecting('ClearTemplateEntries', $body);
// print_r($a);

if ($a -> message == 'templateId is invalid'){echo "id_list_message=t-לא עודכן רשימת תפוצה";}

if ($a -> message == 'ok'){
echo "id_list_message=t-רשימת התפוצה $templateId,אופסה בהצלחה";
}


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 » 22:32 10/04/2018

זייער שיין

קביעתא
הודעות: 377
הצטרף: 16:54 04/04/2016
מיקום: ארץ ישראל
יצירת קשר:

Re: איפוס רשימת תפוצה

שליחהעל ידי קביעתא » 23:39 10/04/2018

אגב יש אפשרות לקבל לקובץ את כל מספרי הטלפון שברשימה ???

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

Re: איפוס רשימת תפוצה

שליחהעל ידי 011371 » 12:45 11/04/2018

אגב יש אפשרות לקבל לקובץ את כל מספרי הטלפון שברשימה ???
ראה מה הכנתי לך כאן

מ.ל.
הודעות: 73
הצטרף: 22:55 11/04/2017

Re: איפוס רשימת תפוצה

שליחהעל ידי מ.ל. » 04:52 22/03/2020

שלום וברכה,
אני מעוניין להשתמש בקוד שנמצא כאן עבור מערכת שברשותי,
אך אינני יודע איך להשתמש ב PHP הזה.
אם מישהו יוכל להדריך אותי איך אני משתמש בקוד הזה במערכת של ימות המשיח, או להגדיר את כ API עבורי, אודה לו מאד.
או אולי אם יש דרך אחרת איך אפשר לעשות הסרה שקטה מבלי להקיש סיסמה.
תודה רבה!!!
בבקשה...

הערה: תבנית רשימת התפוצה צריכה להיות מספר מזהה של ימות ולא מספר סידורי. ראה כאן

בניתי את הקוד על המחלקה של "מאזין נלהב"

דרך אגב, אתה יכול להריץ את הקובץ אוטומטי ע"י האתר הזה

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

<?php

$DID = "0773137770"; // הכנס כאן מספר מערכת
$password = "1234"; // הכנס כאן סיסמת מערכת

$templateId = "123456"; //הכנס כאן את מספר תבנית רשמית התפוצה


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


$body = array
(
// מספר הקמפיין
'templateId' => $templateId,
);

$a = @$con -> connecting('ClearTemplateEntries', $body);
// print_r($a);

if ($a -> message == 'templateId is invalid'){echo "id_list_message=t-לא עודכן רשימת תפוצה";}

if ($a -> message == 'ok'){
echo "id_list_message=t-רשימת התפוצה $templateId,אופסה בהצלחה";
}


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


?>

גבאי
הודעות: 576
הצטרף: 23:08 15/06/2017

Re: איפוס רשימת תפוצה

שליחהעל ידי גבאי » 07:51 22/03/2020

שלום וברכה,
אני מעוניין להשתמש בקוד שנמצא כאן עבור מערכת שברשותי,
אך אינני יודע איך להשתמש ב PHP הזה.
אם מישהו יוכל להדריך אותי איך אני משתמש בקוד הזה במערכת של ימות המשיח, או להגדיר את כ API עבורי, אודה לו מאד.
או אולי אם יש דרך אחרת איך אפשר לעשות הסרה שקטה מבלי להקיש סיסמה.
תודה רבה!!!
בבקשה...

הערה: תבנית רשימת התפוצה צריכה להיות מספר מזהה של ימות ולא מספר סידורי. ראה כאן

בניתי את הקוד על המחלקה של "מאזין נלהב"

דרך אגב, אתה יכול להריץ את הקובץ אוטומטי ע"י האתר הזה

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

<?php

$DID = "0773137770"; // הכנס כאן מספר מערכת
$password = "1234"; // הכנס כאן סיסמת מערכת

$templateId = "123456"; //הכנס כאן את מספר תבנית רשמית התפוצה


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


$body = array
(
// מספר הקמפיין
'templateId' => $templateId,
);

$a = @$con -> connecting('ClearTemplateEntries', $body);
// print_r($a);

if ($a -> message == 'templateId is invalid'){echo "id_list_message=t-לא עודכן רשימת תפוצה";}

if ($a -> message == 'ok'){
echo "id_list_message=t-רשימת התפוצה $templateId,אופסה בהצלחה";
}


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


?>
הרעיון הוא כזה
צריך שרת איחסון שבו יש אתה מכניס את הקוד הנ"ל
(אם אתה מעונין יש שרת איחסון חינמי פה https://www.000webhost.com/cpanel-login?from=panel)
אחרי שאתה מכניס לשם את הקובץ עם הקוד. (כותב בתוך הקוד את המספר מערכת וסיסמא שלך וכן את מזהה הקמפין. כפי שמוסבר פה)
אתה צריך לעשות שלוחה בטלפון מודול

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

type=api
api_link=https://www.abc.co.il/API.aspx
לשנות את הכתובת לכתובת של הקובץ שהעלית לאתר.
ומעכשיו כל מי שנכנס לשלוחה בעצם מפעיל את הקובץ הנ"ל


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

מי מחובר

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