jamied Posted November 25, 2017 Share Posted November 25, 2017 I am working with an api that gives this response in this format each time it is called:> OK|*random sequence of numbers*|http://response.com/0/123456How can i automatically redirect people to response.com url?Below is the current PHP script i am using <?php $url = 'http://example.com/api/'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); Quote Link to comment Share on other sites More sharing options...
requinix Posted November 26, 2017 Share Posted November 26, 2017 First you'll have to parse the response. Any luck with that? What code have you tried? Quote Link to comment Share on other sites More sharing options...
phpmillion Posted November 27, 2017 Share Posted November 27, 2017 1. Use preg_match() to parse this URL (you will need to parse it from $result variable). 2. Use header() to redirect to this URL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.