Php Curl Http Error 400. The Request Is Badly Formed
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Http Error 400. The Request Is Badly Formed. Chrome
the workings and policies of this site About Us Learn more about curl bad request 400 Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow bad request http error 400. the request is badly formed. Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each
Http Error 400 Bad Request
other. Join them; it only takes a minute: Sign up CURL: BAD REQUESt error when trying to call http url up vote 0 down vote favorite 1 I am trying to call an sms api using a http url .I am trying to call the url using curl in php.I get a BAD REQUEST error .Please explain what I
Urlencode() In Php
am doing wrong. // create a new cURL resource $ch = curl_init(); $string1 = "http://api.znisms.com/post/smsv3.asp?userid=alpesh67&apikey=74c6314840a16c5e7db00415a03181f7&message= Congratulation you have been successfully registered in the Placement Management System \n Email:".$email."\n Password:".$password."&senderid=PMS12345&sendto=".$contactno.""; echo $string1; // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $string1); // grab URL and pass it to the browser curl_exec($ch); //close cURL resource, and free up system resources curl_close($ch); //SMS END I get the following error: http://api.znisms.com/post/smsv3.asp?userid=alpesh67&apikey=74c6314840a16c5e7db00415a03181f7&message= Congratulation you have been successfully registered in the Placement Management System Email:alpeshhi@gmail.com Password:123456789&senderid=PMS12345&sendto=9773396773 Bad Request php curl web share|improve this question asked Mar 13 '12 at 11:34 Jonah 42611019 add a comment| 3 Answers 3 active oldest votes up vote 8 down vote accepted You can't use spaces in a URL. You need to url encode this string: &message= Congratulation you have been successfully registered in the Placement Management System \n Email:".$email."\n Password:".$password." http://php.net/manual/en/function.urlencode.php Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. I
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/9683186/curl-bad-request-error-when-trying-to-call-http-url only takes a minute: Sign up Why am I getting a HTTP 400 bad request error? up vote 2 down vote favorite 1 After running this code I am getting HTTP Error 400. The request is badly formed. What should I do? I tried other http://stackoverflow.com/questions/12873555/why-am-i-getting-a-http-400-bad-request-error 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. php http curl http-status-code-400 share|improve this question edited Oct 13 '12 at 13:42 Lee Taylor 4,56572138 asked Oct 13 '12 at 13:27 user1460815 11114 1 and what is request? –Michael Krelin - hacker Oct 13 '12 at 13:29 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote I see this a lot. Usually fixed by running the request through urlencode(). share|improve this answer answered Jul 14 '13 at 21:19 Jay Julian Payne 313139 add a comment| up vote 0 down vote 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 answered Oct 13 '12 at 13:37 GBD 12.2k22437 add a comment| up vote
here for a quick overview of the site Help Center Detailed answers to any questions you http://stackoverflow.com/questions/26887012/bad-request-while-sending-sms-from-php might have Meta Discuss the workings and policies of this https://www.experts-exchange.com/questions/27605053/Problems-With-CURL-and-PHP-returning-error-Bad-Request-Invalid-URL.html site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community http error of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bad Request while sending SMS from php up vote 2 down vote favorite I am using indiasms's api with curl to send sms 1, CURLOPT_URL => $url, CURLOPT_USERAGENT => 'Codular Sample cURL Request' )); $resp = curl_exec($curl); curl_close($curl); ?> Whenever I run this script I get Bad Request HTTP Error 400. The request is badly formed. What i am doing wrong. ?? Update But when i run without curl it works fine Send Message When i click this link it works normally php curl sms-gateway share|improve this question edited Nov 12 '14 at 12:30 asked Nov 12 '14 at 12:26 Cody 466417 Are you URL encoding the message? What does the API documentation say? –ʰᵈˑ Nov 12 '14 at 12:28 Cody, your webservice requires POST method? –Guilherme Nascimento Nov 12 '14 at 12:29 @GuilhermeNascimento no –Cody Nov 12 '14 at 12:31 @ʰᵈˑ there is nothing about URL encoding here –Cody Nov 12 '14 at 12:32 1 I would also guess, that the problem is the encoding of the message.
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Problems With CURL and PHP returning error: Bad Request (Invalid URL) Want to Advertise Here? Solved Problems With CURL and PHP returning error: Bad Request (Invalid URL) Posted on 2012-02-26 PHP 1 Verified Solution 4 Comments 5,876 Views Last Modified: 2012-06-27 I am having issues posting an XML string to a HTTP server. If I use the following code: I get the following data response: Bad Request - Invalid URL HTTP Error 400. The request URL is invalid. My XML output is exactly how the API Requires it. Could there issues using CURL to send to ASPX pages ? Thanks in advance $MUID="AAAA"; $MPWD="BBB"; //Parameters $ProjectID = "63"; $ClientID = "204"; $CampaignId = "529"; $RecipientMobileNumber = "88821111669"; $RecipientFirstName = "GGG"; $RecipientLastName = "RRR"; $RecipientEmail = "greg@dRRR9.com"; $UserId = "13"; $DealId = "3"; $DealRef = "13X3X323409827758"; $url = "http://api.****/request.aspx"; $post_string = ""."