473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cURL question, how to return final URL where Im redirected?

I'm sending a html form with cURL to some file.php which does
something with the sent data and at the end redirects me to some other
URL, which is different every time, something like this:

$ch = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
....
$result = curl_exec($ch);

$result here is a string of the resulting page at the end

I need to return the final URL of where I have been redirected when
sending the request

anyone has an idea?=)
thanks

Jul 13 '07 #1
3 4686
On 13 Jul, 12:45, Mikhail Kovalev <mikhail_kova...@mail.ruwrote:
I'm sending a html form with cURL to some file.php which does
something with the sent data and at the end redirects me to some other
URL, which is different every time, something like this:

$ch = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
...
$result = curl_exec($ch);

$result here is a string of the resulting page at the end

I need to return the final URL of where I have been redirected when
sending the request

anyone has an idea?=)
thanks
Where do you need to return it to, the site that sent it?

Jul 13 '07 #2
On Fri, 13 Jul 2007 04:45:27 -0700, Mikhail Kovalev <mi*************@mail.ru>
wrote:
>I'm sending a html form with cURL to some file.php which does
something with the sent data and at the end redirects me to some other
URL, which is different every time, something like this:

$ch = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
...
$result = curl_exec($ch);

$result here is a string of the resulting page at the end

I need to return the final URL of where I have been redirected when
sending the request
http://uk.php.net/manual/en/function.curl-getinfo.php

CURLINFO_EFFECTIVE_URL ?

Or you could set CURLOPT_HEADERFUNCTION and read the Location headers on the
redirect(s).

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 13 '07 #3
Thanks it nailed it
On 13 Jul, 14:21, Andy Hassall <a...@andyh.co.ukwrote:
On Fri, 13 Jul 2007 04:45:27 -0700, Mikhail Kovalev <mikhail_kova...@mail.ru>
wrote:
I'm sending a html form with cURL to some file.php which does
something with the sent data and at the end redirects me to some other
URL, which is different every time, something like this:
$ch = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
...
$result = curl_exec($ch);
$result here is a string of the resulting page at the end
I need to return the final URL of where I have been redirected when
sending the request

http://uk.php.net/manual/en/function.curl-getinfo.php

CURLINFO_EFFECTIVE_URL ?

Or you could set CURLOPT_HEADERFUNCTION and read the Location headers on the
redirect(s).

--
Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool

Jul 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil Powell | last post by:
I am having trouble retrieving URLs using curl for PHP whereby the URL requires a cookie to produce proper data. I wrote a wrapper class called Timer that will time the execution/download of a...
9
by: Dave Martin | last post by:
I've successfully used CURL to maneuver around and through sites but a new site I've been trying to work with has got me stumped. To retrieve the data I'm trying to get a login is required. If...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
0
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. ...
1
by: devranger | last post by:
Hello, I am in the process of learning PHP CURL and in doing some test examples I am having some issues with CURL that I do not fully understand. I am doing a test to use CURL to post and return...
5
by: turnitup | last post by:
I have a security mechanism that checks that session variables are set, and if not, redirects. It seems, however, that CURL just ignores this statement and completely breaches my security. Does...
0
by: xerc | last post by:
I am trying to create a generic function I can call to download all files from a single remote FTP directory -- using CURL. I want to multi-thread it, but need to get the single thread functionality...
1
by: jeddiki | last post by:
Hi, I am modifying a ipn script for my use and want to fully understand what it is doing. It seems to me that it is trying to do a cUrl and if that fails it uses a fsockopen function. Here are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.