php - How can i POST data to this website using curl -


hello there i'm working on project send sms using http api of clicksend sms i'm trying post data using curl function i'm having difficulties please edit code these post fields method,username,key,to,message,sender , want done using curl function html form. in advance help! `

  // passwords start here.....!!  if ($pass == "jony") {  echo "correct password....!!";  }  else {  echo "wrong password....!! "; exit; } // passwords end here....!! echo "success   "  . $num . "  ";    $loginurl = "https://api.clicksend.com/http/v2/send.php?method=http&username=username&key=key"; $postfields = '&to=' . $num .'&message=' . $msg . '&senderid=' . $sender; $agent = "mozilla/5.0 (windows nt 6.1; wow64; rv:26.0) gecko/20100101 firefox/26.0"; $ch = curl_init();  curl_setopt($ch, curlopt_url,$loginurl); curl_setopt($ch, curlopt_useragent, $agent); curl_setopt($ch, curlopt_post, 1);  curl_setopt($ch, curlopt_postfields,$postfields);  curl_setopt($ch, curlopt_returntransfer, 1);  curl_setopt($ch,curlopt_cookiefile, "cookie.txt"); curl_setopt($ch, curlopt_referer, $reffer);     curl_exec ($ch); ?> 

i assume have blanked out actual username , key in login url, right? if not, need use provided clicksend. no doubt you'll able set api key in account somewhere etc...

also see curlopt_returntransfer set 1, since debugging @ moment should either set 0 (which show 'response' clicksend after running script)

the rest looks fine. once clicksend response rendering page should give better idea of root of problem is.

try running script, tell page says.

<?php   //you *must* define username , key. availible in clicksend dashboard.   $_my_clicksend_username = "clicksendusername";   $_my_clicksend_key = "abc123";   //you *must* define 'to', 'message' , 'senderid'   $to        = "the recipient";   $message   = "the message";   $senderid  = "the sender id";   //tell curl post, , data send.   $url = "https://api.clicksend.com/http/v2/send.php?method=http&username=$_my_clicksend_username&key=$_my_clicksend_key";   $data = '&to=' . $to .'&message=' . $message . '&senderid=' . $senderid;   //now tell curl post data , write outcome on page.    $ch = curl_init();    curl_setopt($ch, curlopt_url, $url);   curl_setopt($ch, curlopt_post, 1);    curl_setopt($ch, curlopt_postfields, $data);    curl_setopt($ch, curlopt_returntransfer, 0);    curl_exec ($ch);   curl_close($ch); ?> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -