html - simulate a link call using php code
i create a link, in html page, that when it is clicked, it calls a URL to another site, that cause the other site to send a response to a different URL (doesnt matter which one).
i create the html link like this:
print "<a class='login' href='$authUrl'>Connect Me!</a>";
then when i click the link, the other site sends the response ok.
now i need to do the above link call , but in php code, which i believe, means call a GET request using curl?
i tried it so many times but i can't seem to make it work like the link click above. This is my code:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 0,
CURLOPT_URL => $authUrl,
)) $result = curl_exec($curl);
$GLOBALS['log']->fatal("error = " . curl_error($curl));
curl_close($curl);
but it doesn't work and the other site doesn't respond.
i get 1 as a result.
did i call the link ok? is it exactly like clicking on the link in the first example?
Answer
Solution:
I use Goutte for that kind of problem. See this repository: https://github.com/fabpot/goutte
It can fill forms or click links and buttons and may help you.
Answer
Solution:
You should use:
Otherwise the page content is not returned.