title: Calling api using php curl?
body: <p>I am calling a sms gateway api and below is my code.</p>
  <pre><code>$otp=&quot;1234&quot;;
  $mobile_number=1234567890;
  $username = 123456;
  $hash = 1234;
  $from = &quot;SENDER&quot;;
  $message=&quot;Your one time password is &quot;.$otp.&quot;&quot;;
  
  $payload = &quot;username=&quot;.$username.&quot;&amp;password=&quot;.$hash.&quot;&amp;to=&quot;.&quot;91&quot;.$mobile_number.&quot;&amp;from=&quot;.$from.&quot;&amp;text=&quot;.$message;
  $ch = curl_init('https://sms.zestwings.com/smpp.sms?');
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch); // This is the result from the API
  curl_close($ch);
  echo json_encode($result);
  return $result;
  </code></pre>
  <p>When I hit the url in browser using all the details like username, password,sender, phone number, OTP is sent to my mobile number and when I try using curl method it gives me error message as follows:</p>
  <blockquote>
  <p>Notice: Undefined index: username in /var/www/html/api/index.php on line 232</p>
  <p>Notice: Undefined index: password in /var/www/html/api/index.php on line 232
  User account Deactivated</p>
  </blockquote>
  <p>I don't have any index.php page in server only otp.php page is there, Can anyone me suggest me what went wrong.</p>