Use file_get_contents with a cookie to access a remote page, but the page jumps to another page, now the question is whether to get the URL of the post-jump page? I know that using get_headers is a way to get headers such as cookies, but how do I get a URL?
Reply to discussion (solution)
Get_headers can also get the URL of the jump
File_get_contents automatically jumps to the new destination URL based on the HTTP header's instructions
If the destination URL has a jump, there is a location entry in the result of the get_headers.
And Get_headers will also track the final target, so the value of the last location item is what you want.
$a = Get_headers ($url, 1), if (Isset ($a [' Location ')}) { $url = Is_array ($a [' location '])? Array_pop ($a [' Location ']): $a [' Location '];}
You know the original link, open directly in the browser, do not know it jumps to which link?
File_get_contents automatically jumps to the new destination URL based on the HTTP header's instructions
If the destination URL has a jump, there is a location entry in the result of the get_headers.
And Get_headers will also track the final target, so the value of the last location item is what you want.
$a = Get_headers ($url, 1), if (Isset ($a [' Location ')}) { $url = Is_array ($a [' location '])? Array_pop ($a [' Location ']): $a [' Location '];}
But there's no location in the header. In fact, I do is for discuz automatic post, after the post to jump to the content page, now I want to get new posts Id,url inside there is this.
He had only one verse 200, so it didn't happen. HTTP Jump
Instead, include the posts page directly on the form acceptance page
You can only analyze the page content to find out the post ID
In fact, it's simple: Find the code for the response.