开发者

How can i get a website to open up a page server side?

开发者 https://www.devze.com 2023-04-10 07:38 出处:网络
I want to create a callback feature. E.g. The client does something but then we need to open up a page with a few GET variables to one of our partners. Therefore id like to make a PHP script which ope

I want to create a callback feature. E.g. The client does something but then we need to open up a page with a few GET variables to one of our partners. Therefore id like to make a PHP script which opens a website with all the data in the URL (The user shouldn开发者_高级运维t see this, it should be done server sided). How could I do this thanks. A bit like some IPN systems. Sorry that the question is not very well constructed if you need more detail ill provide more.


See fopen. If you are expecting to get a response from the other server, you can use file_get_contents to read the response.


Take a look at CURL. It's a really powerful API.


I like fopen okay, though fsockopen is more appropriate for a remote URL, but I find CURL to be much more powerful. You'll need to have compiled PHP with support for CURL, but it's a default package on many systems. You can check if your current system supports it by pulling up a phpinfo() page and looking for CURL.

The benefit of using CURL is you get really fine grained control over the request and how to handle the response. The php docs have a fairly concise example of how to use CURL; due to the number of options available it can get verbose quickly. The functions you'll use most are curl_init, curl_setopt and curl_exec

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号