Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?
  2. $url = "https://example.com:2083/login?user=USER&pass=PASS";
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, $url); //set url
  5. curl_setopt($ch, CURLOPT_HEADER, true); //get header
  6. curl_setopt($ch, CURLOPT_NOBODY, true); //do not include response body
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //do not show in browser the response
  8. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //follow any redirects
  9. curl_exec($ch);
  10. $new_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); //extract the url from the header response
  11.  
  12. $response = curl_exec($ch);
  13. curl_close($ch);
  14. echo $new_url
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement