I'm using wp_remote_post and download_url to fetch a zip file from a site using aMember to manage users and access to files. The download_url function works perfectly if the file is not restricted (some files are marked as free and do not require login).
$response = wp_remote_post( 'http://visit.me/member/login.php', array( 'headers' => array(), 'body' => array( 'amember_login' => $_POST['username'], 'amember_pass' => $_POST['password'] ), 'cookies' => array() ) ); //response check goes here $temp_file = download_url( 'http://visit.me/member/downloads/file.zip' );
However, I need to set a cookie for the login and set it properly. In the code above, I've tried
'cookies' => array('cookie' => 'cookiejar.txt')
'cookies' => array('cookiejar.txt')
and variations adding a full path but keep getting
Call to a member function getHeaderValue() on a non-object in
What's the correct way of writing this parameter? I haven't found a single example of its usage, either in the Codex or any wp-related blog.