What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help - Curl

PHP help - Curl
Author: Message:
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. PHP help - Curl
Hey,

Haven't been here for a while but I'm confused on something related to PHP. I've been out of the internet world for about 6-8 months really which means im mentally fucked when it comes to PHP.

code:
<?
function fetch($url,$post=false,$cookie=true,$timeout=1) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
}
if ($post) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, TRUE);
}
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt($ch, CURLOPT_HEADER, TRUE); //debug
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$cookie=tempnam('','');
$url='http://www.website.com/fsock.php';
$post='username=Nathan1&password=test';
fetch($url,$post,$cookie);

$url='http://www.website.com/vote.php?account=nathan1&site=2';
echo fetch($url,$post,$cookie);

#$url='http://www.website.com/vote/vote.php';
#echo fetch($url,false,$cookie);

?>


Basically it logs in okay, but then when it comes to clicking the link it doesn't work, it redirects to the home page (which after some investigation = not logged in) which makes me think the cookie isn't being stored.
Anyone got any ideas on how to make the cookie last longer or be stored so it'll work?

Thanks :D

This post was edited on 06-17-2009 at 04:43 PM by Nathan.
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-17-2009 04:42 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
PHP help - Curl - by Nathan on 06-17-2009 at 04:42 PM
RE: PHP help - Curl - by WDZ on 06-17-2009 at 06:30 PM
RE: PHP help - Curl - by Nathan on 06-17-2009 at 06:38 PM
RE: PHP help - Curl - by MeEtc on 06-18-2009 at 02:45 AM
RE: PHP help - Curl - by Nathan on 06-18-2009 at 09:43 AM
RE: PHP help - Curl - by Ezra on 06-18-2009 at 12:01 PM
RE: PHP help - Curl - by Nathan on 06-18-2009 at 12:19 PM
RE: PHP help - Curl - by andrewdodd13 on 06-18-2009 at 09:59 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On