בPOST או בGET?
אם מדובר בGET הכל הרבה יותר קל, אתה יכול עם CURL
PHP קוד:
$url_c = "http://".$host.":".$port.$path."?".$query; // Generates the URL;
$curl = curl_init($url_c);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl); //Sends the request;
echo $content; // Echos the respond from application server;
ואפשר גם עם FSOCKOPEN, אבל לי באופן אישי CURL עבד יותר טוב עם השרתים בארץ
PHP קוד:
$fp = fsockopen("$host", $port, $errno, $errstr, 30); // Opens a socket to the Application server
if (!$fp) { // Verifies that the socket has been opened and sending the message;
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET $path?$query HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128); // Echos the respond from application server (you may replace this line with an "Message has been sent" message);
}
fclose($fp);
}
הקודים הם מתוך קוד לדוגמא שכתבתי לחברה שמספקת WEB SERVICE של SMSים.
אם אתה צריך משהו מעבר, דבר איתי.