It is currently April 27th, 2024, 11:37 am

Handling Cookie and HTTP Header Variables

Get help with creating, editing & fixing problems with skins
User avatar
kanine
Posts: 62
Joined: June 29th, 2012, 9:09 am

Handling Cookie and HTTP Header Variables

Post by kanine »

I'm working on updating my BigPond Usage skin, which has a fairly complicated set of steps required to login and and retrieve data usage information.

The two steps to the process are to login in with a username and password, which will return a Cookie and then use this Cookie and the HTTP Header "Referer" to retrieve usage information.

This has been done successfully using PHP coding, but is there any way to do this more natively in Rainmeter without relying on a call to this PHP app?

Example PHP Calls

Code: Select all

...
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://signon.bigpond.com/login');
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . $username . '&password=' . $password);
...
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://usagemeter.bigpond.com/daily.do?');
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Cookie:BPSESSION='.$bpsession, 'Referer:https://signon.bigpond.com/login?goto=https%3A%2F%2Fusagemeter.bigpond.com%3A443%2Fdaily.do'));
	$output = curl_exec($ch);
Any help would be appreciated.
Alex Becherer

Re: Handling Cookie and HTTP Header Variables

Post by Alex Becherer »

there is no cookies support in the webparser plugin.
i think you should continue to use curl for that.
User avatar
Mellin
Posts: 4
Joined: December 27th, 2012, 1:59 pm
Location: Warsaw

Re: Handling Cookie and HTTP Header Variables

Post by Mellin »

Actually it can, but not directly. I found a way ... I wrote a program in C #:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;

namespace BiowareDownload
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main()
{
string ErrorPath = @"C:\Errors.txt";

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

string SavePath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Rainmeter\Skins\Mass Effect 3 PL\Galaxy at War\";

try
{
if (!Directory.Exists(SavePath)) Directory.CreateDirectory(SavePath);
}
catch (Exception ex)
{
File.WriteAllText(ErrorPath, ex.Message);
return -1;
}

SavePath = SavePath + "Mass Effect 3 N7 HQ Main.txt";


WebBrowser MyBrowser = new WebBrowser();
try
{
MyBrowser.Navigate("http://social.bioware.com/n7hq");

while ((MyBrowser.Document == null) || MyBrowser.IsBusy)
{
Application.DoEvents();
}

if (File.Exists(SavePath)) File.Delete(SavePath);
File.WriteAllText(SavePath, MyBrowser.DocumentText);
}
catch (Exception ex)
{
File.WriteAllText(ErrorPath, ex.Message);
MyBrowser.Dispose();
return -1;
}

MyBrowser.Dispose();

return 0;
//Application.Run(new Form1());
}
}
}
This program downloading page source file from http://social.bioware.com/n7hq and saves it to a text file \ Documents \ Rainmeter \ Skins \ Mass Effect 3 EN \ Galaxy at War \ Mass Effect 3 N7 main.txt HQ, from which you can extract information with WebParser plugin. You just need to add the regular firing of the program to your skins and you're done! It works for me.