Take the 2-minute tour ×
$url ="http://absolutesms.com/Sendsms.aspx?userid=userid&password=password&clientid=clientid&senderid=absolute&mobilenumber=919000024365&smsmessage=SingleMessage".$request;
$ch = curl_init($url);
$curl_scraped_page = curl_exec($ch);
echo $curl_scraped_page;

After running this code I am getting HTTP Error 400. The request is badly formed. What should I do? I tried other url they are working fine the only problem is with this. If I copy this url in browser it's working but it's giving error 400 when I put it and run it in curl.

share|improve this question
and what is request? –  Michael Krelin - hacker Oct 13 '12 at 13:29

3 Answers 3

I see this a lot. Usually fixed by running the request through urlencode().

share|improve this answer

Try building URL with http_build_query as below

$url = 'http://absolutesms.com/Sendsms.aspx?' . http_build_query(array(
    'userid' => $userid,
    'clientid' => $clientid,
///... continue

The problem is probably due to unescaped characters that have special meanings in URLs.

http_build_query escapes them for you safely.

share|improve this answer

You are appending $request at the end of the assignment to $url but you don't show us what $request contains.

Chances are that the value of $request tacked on the end that way is making the URL invalid.

I would expect to at least see a & at the end of the hardcoded URL string if you are going to append $request like that (although as @MichaelKrelin-hacker points out, this is unlikely to be the source of this specific error).

share|improve this answer
The lack of & doesn't make URL invalid, even if it glues the next parameter to the last one. What is most likely to make url invalid is either its size or perhaps some awfully invalid characters. –  Michael Krelin - hacker Oct 13 '12 at 13:37
@MichaelKrelin-hacker Good point. Edited the answer. –  Trott Oct 13 '12 at 13:41

Your Answer


