Bonjour à tous,

Apres avoir longtemps cherché, je me permets de poster ce message.

J'essaye désespérément de transformer un Google chart en image.
Tout en passant par le proxy de mon entreprise.
J'utilise donc les fonctions curl_init() et curl_setopt().

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 
public function file_get_contents_via_proxy( $sURL, $sProxyAddress, $iProxyPort, $sProxyUsername, $sProxyPassword )
{
$rcURLhandle = curl_init($sURL);
curl_setopt($rcURLhandle, CURLOPT_HEADER, 0);
curl_setopt($rcURLhandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rcURLhandle, CURLOPT_BINARYTRANSFER,1);
curl_setopt($rcURLhandle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($rcURLhandle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($rcURLhandle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($rcURLhandle, CURLOPT_PROXY, sprintf('%s:%s',$sProxyAddress,$iProxyPort));
curl_setopt($rcURLhandle, CURLOPT_PROXYUSERPWD, sprintf('%s:%s',$sProxyUsername,$sProxyPassword));
curl_setopt($rcURLhandle, CURLOPT_RETURNTRANSFER, true);
$sData = curl_exec($rcURLhandle);
return ( curl_errno($rcURLhandle) > 0 ) ? false : $sData ;
}
 
$url = 'http://chart.apis.google.com/chart?chs=500x50&chf=bg,s,ffffff&cht=ls&chd=t:23.52,20.58,&chco=0066ff'; 
 
$contents = $this->file_get_contents_via_proxy($url, 'monproxy', 8080, Mondomaine\monid, monpassword);
 
 
file_put_contents($name.'.png', $contents);
Ce code marche.

Cependant, si l'url est plus grande
comme :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
$url = 'http://chart.apis.google.com/chart?chs=500x50&chf=bg,s,ffffff&cht=ls&chd=t:23.52,20.58,26.47,23.52,23.52,23.52,100.00,0.00,23.52,23.52,27.94,20.58,23.52&chco=0066ff';
Alors ça ne marchera plus.

Quelqu'un aurait il une solution?

Je vous remercie à l'avance de votre aide,

Merlin