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_URL => $authUrl,

)) $result = curl_exec($curl);

$GLOBALS['log']->fatal("error = " . curl_error($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?




I use Goutte for that kind of problem. See this repository:

It can fill forms or click links and buttons and may help you.




You should use:


Otherwise the page content is not returned.

People are also looking for solutions to the problem: jquery - How to add php code in JS file


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.