Intersud
This commit is contained in:
parent
431d0163a9
commit
5161eb4ed8
154
library/SdMetier/Intersud/Service.php
Normal file
154
library/SdMetier/Intersud/Service.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
class SdMetier_Intersud_Service
|
||||
{
|
||||
/**
|
||||
* Stockage du cookie
|
||||
* @var string
|
||||
*/
|
||||
protected $ckfile;
|
||||
|
||||
protected $login = 'YLENA';
|
||||
protected $pass = 'WYLFE';
|
||||
|
||||
/**
|
||||
* Gestion des demandes d'enquêtes au service Infogreffe
|
||||
*/
|
||||
public function __construct(){}
|
||||
|
||||
public function setDemandeur()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function setEnquete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function call()
|
||||
{
|
||||
$this->ckfile = __DIR__.'/'.uniqid('cookie-');
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
|
||||
// --- Authentification
|
||||
$url = 'http://www.intersud.fr/espace_client/';
|
||||
$data = array(
|
||||
'login' => $this->login,
|
||||
'pwd' => $this->pass,
|
||||
);
|
||||
$result = $this->page($url, $data);
|
||||
|
||||
|
||||
// --- Post de la demande
|
||||
$url = 'http://intersud.fr/espace_client/demande_enquete.php';
|
||||
|
||||
|
||||
$data = array(
|
||||
//Expediteur - Email
|
||||
'email_exp' => 'support@scores-decisions.com',
|
||||
//Type enquete - Prestation Nationales
|
||||
'type_enk' => $enqType, // 0=Premier, 1=Gold, 2=Distrimat, 3=Star, 4=Avis bancaire, 5=Autre
|
||||
'delai_enk' => $enqDelai, // 6=24h, 7=72h, 8=+de5jours
|
||||
//Type enquete - Prestation Internationales
|
||||
|
||||
//Société
|
||||
'soc' => $tabIdentite['Nom'],
|
||||
'cible_enk' => 9, // 9
|
||||
'siret' => $siren,
|
||||
'acti' => '',
|
||||
'soc_exp' => $tabInterSud['soc_exp'],
|
||||
|
||||
'nom_diri' => '',
|
||||
'adr' => $tabIdentite['Adresse'],
|
||||
'ref_exp' => $tabInterSud['ref_exp'],
|
||||
'autre_type_enk' => '', // Texte libre
|
||||
'adr2' => $tabIdentite['Adresse2'],
|
||||
|
||||
'ville' => $tabIdentite['Ville'],
|
||||
'cp' => $tabIdentite['CP'],
|
||||
'pays' => '', // International ?
|
||||
'nom_exp' => $tabInterSud['nom_exp'],
|
||||
'tel' => $tabIdentite['Tel'],
|
||||
'port' => $infoEnq['Entrep']['AutreTel'],
|
||||
'tel_exp' => $tabInterSud['tel_exp'],
|
||||
'bank' => trim(implode(' ', $infoEnq['Entrep']['Rib'])),
|
||||
'int_enk' => $tabInterSud['int_enk'], // International ?
|
||||
'encours' => $infoEnq['Encours'],
|
||||
'nb_ech' => $infoEnq['NbEcheances'],
|
||||
'delai2_enk' => $tabInterSud['delai2_enk'], // International ?
|
||||
|
||||
'cred' => '',
|
||||
'comment' => urlencode($comment),
|
||||
'val_ret' => $tabInterSud['val_ret'],
|
||||
);
|
||||
|
||||
$result = $this->page($url, $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function page($url, $curl_data = '', $override = null)
|
||||
{
|
||||
//$user_agent = 'Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1';
|
||||
//$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
$user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
|
||||
$verbose = false;
|
||||
$post = false;
|
||||
$fields = '';
|
||||
if (is_array($curl_data) && count($curl_data)>0) {
|
||||
foreach($curl_data as $key=>$value) {
|
||||
$fields .= $key.'='.$value.'&';
|
||||
}
|
||||
rtrim($fields,'&');
|
||||
$post = true;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
CURLOPT_RETURNTRANSFER => true, // return web page
|
||||
CURLOPT_HEADER => false, // don't return headers
|
||||
CURLOPT_FOLLOWLOCATION => false, // follow redirects
|
||||
CURLOPT_ENCODING => "", // handle all encodings
|
||||
CURLOPT_USERAGENT => $user_agent, // who am i
|
||||
CURLOPT_AUTOREFERER => true, // set referer on redirect
|
||||
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
|
||||
CURLOPT_TIMEOUT => 120, // timeout on response
|
||||
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
|
||||
CURLOPT_POST => $post, // i am sending post data
|
||||
CURLOPT_POSTFIELDS => $fields, // this are my post vars
|
||||
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
|
||||
CURLOPT_SSL_VERIFYPEER => false, //
|
||||
CURLOPT_VERBOSE => $verbose , //
|
||||
//CURLOPT_COOKIESESSION => true,
|
||||
CURLOPT_COOKIEFILE => $ckfile,
|
||||
CURLOPT_COOKIEJAR => $ckfile, // Stockage du cookie de session
|
||||
);
|
||||
|
||||
//Override define CURL option
|
||||
if (is_array($override) && count($override)>0 ) {
|
||||
$options = $override + $options;
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch,$options);
|
||||
$content = curl_exec($ch);
|
||||
$err = curl_errno($ch);
|
||||
$errmsg = curl_error($ch) ;
|
||||
$header = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
//Rewrite encoding to UTF-8
|
||||
//text/html; charset=ISO-8859-1
|
||||
//$encoding = getPageHeader('text\/html; charset=', '', $header['content_type']);
|
||||
//$encoding = 'ISO-8859-1';
|
||||
//$content = iconv($encoding, 'UTF-8//TRANSLIT', $content);
|
||||
|
||||
// $header['errno'] = $err;
|
||||
// $header['errmsg'] = $errmsg;
|
||||
// $header['content'] = $content;
|
||||
return array('header'=>$header, 'content'=>$content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user