Thanks for the help guys. I figured it out using curl, and some example scripts posted online. I found the original script here and modified it to suit my needs.
Here’s a dummy copy of the script in case anyone ever needs help with the same question.
[php]<?php
//The site you want to login to.
$login_url = ‘http://www.testsite.com/login/’;
/*
To get this info go to the site you want to login to and view the source, look for
name=" to find out what each value is called, to learn more check out HTML form posting.
*/
$post_data = ‘login=PUTYOURLOGINNAMEHERE&password=PUTYOURPASSWORDHERE’;
//Create a curl object
$ch = curl_init();
//Set the useragent
$agent = $_SERVER[“HTTP_USER_AGENT”];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $login_url );
//This is a POST query
curl_setopt($ch, CURLOPT_POST, 1 );
//Set the post data
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//We want the content after the query
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Follow Location redirects
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
/*
Set the cookie storing files
Cookie files are necessary since we are logging and session data needs to be saved
*/
curl_setopt($ch, CURLOPT_COOKIEJAR, ‘cookie.txt’);
curl_setopt($ch, CURLOPT_COOKIEFILE, ‘cookie.txt’);
//Execute the action to login
$postResult = curl_exec($ch);
/*
What this part does is it searches the post login page for the term ?value=, returns
what character it is in the string, adds 7 (the length of ?value=) and delivers the next
3 characters (the part I’m looking for) into $value
*/
$value = substr($postResult, (strpos($postResult, ‘?value=’) + 7), 3);
?>[/php]