I'm working with a sms gateway thing, now i have to pass a url via GET or POST. i'm tried with fopen("http://api.studentmug.com/bulksms/sms.php?Username=<something>&Password=<something>", "r"); like that. but it didn't worked. Please help me guys. i'm also used curl_init(); it is replying Bad Request.

Guys please help me with this.

Thanks in advance

Recommended Answers

All 3 Replies

fopen may not be allowed. "Bad Request" usually means you did not provide all/correct data. Hard to help you without knowing the API, nor seeing your code.

Hi,

If you want to pass a url via GET, which means to add that url in the link address, try with: file_get_contents('http://domain/page.php?name='. rawurlencode($the_url_to_pass)); , or with cUrl, but adding that url in the address encoding with rawurlencode().

commented: nice +1
fopen("http://api.studentmug.com/bulksms/sms.php?Username=<something>&Password=<something>", "r");

Try using the local address to the file instead eg:

fopen("C://webhosting/studentmug.com/api/bulksms/sms.php?Username={$username}&Password={$password}", "r");

If that doesnt work you could combine it with what Marplo said and use file_get_contents() - i use file_get_contents with GET variables so i know that one will translate a web address

But is there any reason you cant use require('bulksms/sms.php'); ?

Then you have all the variables you had access to in the calling page eg.

index.php

<?php
$user = 'test';
$password = '1234';
require('bulksms/sms.php');

var_dump($success);
?>

bulksms/sms.php

<?php
if($password == '1234'){
    $success = true;
}else{
    $success = false;
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.