通过curl进行magento管理员登录 [英] magento admin login through curl

查看:84
本文介绍了通过curl进行magento管理员登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦登录成功,我想通过curl发布magento管理员用户名和密码,应重定向到magento管理员仪表板. 我该怎么做? 基本上,magento登录需要以下信息:

I want to post the magento admin username and password through curl once the login is successful should redirect to the magento admin dashboard. How can i do it? Basically magento login requires this information:

require_once ("magento\app\Mage.php" );
umask(0);

// Initialize Magento
Mage::app("default");

// You have two options here,
// "frontend" for frontend session or "adminhtml" for admin session
Mage::getSingleton("core/session", array("name" => "adminhtml"));
$session = Mage::getSingleton("admin/session");

我该如何进行?

推荐答案

<?php
require_once 'app/Mage.php';
umask(0);
$app = Mage::app('default');

Mage::getSingleton('core/session', array('name' => 'adminhtml'));

// supply username
$user = Mage::getModel('admin/user')->loadByUsername('adminusername');

if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {
  Mage::getSingleton('adminhtml/url')->renewSecretUrls();
}

$session = Mage::getSingleton('admin/session');
$session->setIsFirstVisit(true);
$session->setUser($user);
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
Mage::dispatchEvent('admin_session_user_login_success',array('user'=>$user));

if ($session->isLoggedIn()) {
  echo("logged in");
}

这篇关于通过curl进行magento管理员登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆