Je dois me connecter avec un script PHP qui utilise CURL sur un site web Joomla, afin d'accéder à une page privée qui doit être traitée, mais nonobstant plusieurs tentatives que j'ai faites, je avoir toujours une erreur 403 J'ai fait une chose similaire avec d'autres sites Web et cela a fonctionné.CURL se connecter par script à un site web Joomla
Script J'utilise:
$uname = "id";
$upswd = "pswd";
$url = "http://www.somewebpage.com";
$agent = "'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6'";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, './cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, './cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_REFERER, $url1);
// POST fields
$postfields = array();
$postfields['username'] = urlencode($uname);
$postfields['passwd'] = urlencode($upswd);
$postfields['remember'] = 'yes';
$postfields['option'] = 'login';
$postfields['op2'] = 'login';
$postfields['return'] = urlencode($url);
$postfields['message'] = '0';
$postfields['force_session'] = '1';
$postfields['j3b00d36f4336137f4f03335c5eee6440'] = '1';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);
Le nom d'utilisateur et mot de passe, ainsi que l'URL du site que je utilise fonctionnent parfaitement.
Ceci est le résultat je reçois:
HTTP/1.1 100 Continue
HTTP/1.1 403 Forbidden
Date: Sat, 06 Feb 2010 08:29:36 GMT
Server: Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.10
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
Y at-il quelque chose de mal dans ma demande de CURL? Ou y a-t-il une limite avec la connexion à distance Joomla?
Merci pour vos suggestions!
Je pensais aussi ceci. BTW, il échoue également par CURL en ligne de commande ... – Paryeshakaya
Si je comprends bien, vous n'avez pas accès aux journaux du serveur pour voir quelle erreur il produit? –
Malheureusement pas :-( – Paryeshakaya