Paulkirkewalker Posted May 6, 2007 Share Posted May 6, 2007 Hi there, Can any of you nice people see what's wrong with this snippet of PHP code using cURL? I'm really not that familiar with the library so I'm really just amending existing scripts. My thoughts arethat the credentials are not being encoded into the URL (maybe?). Thanks in advance, Paul. <?php /* Constants */ $bcUser = 'yyyyyyy'; $bcPass = 'xxxxxxxx'; $bcURL = 'http://service.bulletinconnect.net/api/1/sms/in'; $bcRatecode = FALSE; /* Send the request */ RequestIncoming($bcUser, $bcPass); /*RequestIncoming Function */ function RequestIncoming($user, $pass) { global $bcURL; print 'user: ' . $user . '<p>'; print 'pass: ' . $pass . '<p>'; $data = "userId=".urlencode($user) . "&password=".urlencode($pass); print 'data: ' . $data; $cUrl = curl_init(); curl_setopt($cUrl, CURLOPT_URL, $bcURL); curl_setopt($cUrl, CURLOPT_HEADER, 'Content-type: application/x-www-form-urlencoded'); curl_setopt($cUrl, CURLOPT_GET, 1); curl_setopt($cUrl, CURLOPT_GETFIELDS, $data); curl_setopt($cUrl, CURLOPT_TIMEOUT, 30); curl_exec($cUrl); $code = curl_getinfo($cUrl, CURLINFO_HTTP_CODE); curl_close($cUrl); return $code; print 'code: ' . $code; } Quote Link to comment https://forums.phpfreaks.com/topic/50293-curl/ Share on other sites More sharing options...
btherl Posted May 7, 2007 Share Posted May 7, 2007 There's no "GETFIELDS" .. just alter the url like this: $get_url = $bcURL . '?' . $data; Then get rid of the HEADER, GET and GETFIELDS lines. As GET is the default action, there is no need to specify that curl should use it. Quote Link to comment https://forums.phpfreaks.com/topic/50293-curl/#findComment-246937 Share on other sites More sharing options...
Paulkirkewalker Posted May 7, 2007 Author Share Posted May 7, 2007 Hi, Thanks for helping me out, I'm absolutely stuck with this one! I'm confused about where the line $get_url = $bcURL . '?' . $data; should go though. Should it be like this? I guess not because I'm still getting the same error message. Thanks, Paul. /* Constants */ $bcUser = 'xxxxx'; $bcPass = 'yyyyy'; $bcURL = 'http://service.bulletinconnect.net/api/1/sms/in'; $bcRatecode = FALSE; /* Send the request */ RequestIncoming($bcUser, $bcPass); /*RequestIncoming Function */ function RequestIncoming($user, $pass) { global $bcURL; print 'user: ' . $user . '<p>'; print 'pass: ' . $pass . '<p>'; $data = "userId=".urlencode($user) . "&password=".urlencode($pass); print 'data: ' . $data; $get_url = $bcURL . '?' . $data; $cUrl = curl_init(); curl_setopt($cUrl, CURLOPT_URL, $bcURL); curl_setopt($cUrl, CURLOPT_TIMEOUT, 30); curl_exec($cUrl); $code = curl_getinfo($cUrl, CURLINFO_HTTP_CODE); curl_close($cUrl); return $code; print 'code: ' . $code; } Quote Link to comment https://forums.phpfreaks.com/topic/50293-curl/#findComment-247123 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.