Php 登录到Channel Advisor
我正在尝试登录channel advisor,但它输出一个错误:HTTP/1.1 302临时移动 但上周,我登录并检索数据时,它运行得非常完美,现在我再次运行时,它出现了一个错误 这是我的密码:Php 登录到Channel Advisor,php,curl,Php,Curl,我正在尝试登录channel advisor,但它输出一个错误:HTTP/1.1 302临时移动 但上周,我登录并检索数据时,它运行得非常完美,现在我再次运行时,它出现了一个错误 这是我的密码: $pages = array('home' => 'https://login.channeladvisor.com/?gotourl=https%3a%2f%2fcomplete.channeladvisor.com%2f', 'login' => 'ht
$pages = array('home' =>
'https://login.channeladvisor.com/?gotourl=https%3a%2f%2fcomplete.channeladvisor.com%2f',
'login' =>
'https://login.channeladvisor.com/?gotourl=https%3a%2f%2fcomplete.channeladvisor.com%2f',
'data' =>
'https://merchant.channeladvisor.com/AM/MyInventory/View_Inventory.aspx?apid=32001263');
$ch = curl_init();
//Set options for curl session
$options = array(CURLOPT_USERAGENT => 'Mozilla/12.0 (compatible; MSIE 6.0; Windows NT 5.1)',
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_HEADER => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_COOKIEFILE => 'cookies.txt',
CURLOPT_COOKIEJAR => 'cookies.txt');
//Hit home page for session cookie
$options[CURLOPT_URL] = $pages['home'];
curl_setopt_array($ch, $options);
//curl_exec($ch);
//Login
$options[CURLOPT_URL] = $pages['login'];
$options[CURLOPT_POST] = TRUE;
$options[CURLOPT_POSTFIELDS] = 'username=xxxxx@gmail.com&password=xxxxxxx';
$options[CURLOPT_FOLLOWLOCATION] = false;
curl_setopt_array($ch, $options);
curl_exec($ch);
//Hit data page
$options[CURLOPT_URL] = $pages['data'];
curl_setopt_array($ch, $options);
$data = curl_exec($ch);
//Output data
echo $data;
//Close curl session
curl_close($ch);
我认为您应该从Channel Advisor处理此类更新,因此,遵循重定向 因为我不认为这是使用curl登录Channel Advisor的常见方式,所以每次Channel Advisor更新时都需要更新代码。当我们只能使用curl来检索谷歌分析数据时,它还记得我:每次他们更新登录系统时,你都必须重写自己的curl登录方法——很无聊 您可以阅读以下标题:带卷曲的位置。基本上:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
if(preg_match('#Location: (.*)#', $a, $r))
$l = trim($r[1]);
如果您正在从查找数据'https://merchant.channeladvisor.com/AM/MyInventory/View_Inventory.aspx“为什么不改用API呢
如果您只想导出库存信息,那么ChannelAdvisor有自己的UI可用库存导出服务。至少,您可以自动执行代码以启动该功能,并下载导出的csv或tab delim文件: