It is currently April 27th, 2024, 1:08 pm

Way to Specify HTTP Header?

Get help with creating, editing & fixing problems with skins
User avatar
SlimJimGuyMan
Posts: 2
Joined: November 6th, 2011, 5:43 am

Way to Specify HTTP Header?

Post by SlimJimGuyMan »

From within Rainmeter, or even a Lua script, is there any way to make an HTTP request with header parameters specified? In curl, this is done with the --header option. I could use luacurl but of course external Lua modules are not (yet?) supported by Rainmeter.

If I need to be more specific, I'm working on a way to retrieve an unread message count from Google Reader. It requires an AUTH token to be supplied in the HTTP request header. I can easily obtain the Google AUTH token from within Rainmeter using the WebParser plugin and Google's ClientLogin service. To request the actual unread list from Google Reader, the "Authorization" HTTP header field needs to be supplied and this is where I'm stuck.

If anyone has any suggestions, let me know.
- SlimJimGuyMan -
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Way to Specify HTTP Header?

Post by jsmorley »

There really is no way within the Rainmeter environment today. WebParser does not support cookies or other authentication other than http://username:passw@somesite.com on the URL, and as you say, Lua does not yet support external compiled libraries like LuaCURL.

It could probably be done if you wanted to create some addon application in AutoIt or some other language, or a plugin in C++ or C#, but not with anything in Rainmeter itself.
User avatar
Mellin
Posts: 4
Joined: December 27th, 2012, 1:59 pm
Location: Warsaw

Re: Way to Specify HTTP Header?

Post by Mellin »

I wrote such a program in C# for my Rainmeter skins. If you want, you can use it.:
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 HQ main.txt **, 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.