如果主机没有CURL扩展,如何通过php发送带有参数的get请求


How to send A get Request by php with parameters if the hosting don't have the CURL extension?

我需要在用户提交表单时发送短信,我有两种方式通过javascript发送它

$.ajax({
        url: encodeURI('http://gate.smsaero.ru/send/?user=myuser&password=mypassword&to=4920942894&text=test&from=fromTest'),
        type: 'GET',
        crossDomain: true,
        dataType: 'jsonp',
        success: function() { alert("Success"); },
        error: function() { alert('Failed!');
 }

但在这里我有一个问题,我得到一个关于登录和密码不正确的错误,这里是一个编码问题或什么可能?

或者通过带参数的php发送,但是主机不提供CURL库,我怎么发送?

在PHP中,您可以尝试:

$result = file_get_contents('http://gate.smsaero.ru/send/?user=myuser&password=mypassword&to=4920942894&text=test&from=fromTest');