Quantcast
Channel: Forum Microsoft Identity Manager
Viewing all articles
Browse latest Browse all 6944

Password Reset Portal SMS Gate Not Working

$
0
0

trying Microsoft code to enable One-Time Password with SMS Gate, no luck to make it work. Anyone can advise what's wrong of this code? 

Customer sms gateway requires POST method with 3 parameters: "password", "hp" and "smsmessage"

namespace Microsoft.IdentityManagement.Samples
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Net;
    using System.Text;
    using Microsoft.IdentityManagement.SmsServiceProvider;
    using System.Web;
    using System.Security.Cryptography;
    using System.IO;

    public class SmsServiceProvider : ISmsServiceProvider
    {
        public void SendSms(string mobileNumber,
                            string message,
                            Guid requestId,
                            Dictionary<string, object> deliveryAttributes)
        {
            mySMSProvider.SendSms(mobileNumber, message);
        }
    }

    class mySMSProvider
    {
        static string RequestURL = "http://smsgw.abc.com/smsgateway/smsforad.php";
        mySMSProvider()
        {
        }
        public static int SendSms(string userMobileNumber, string message)
        {
            WebClient wc = new WebClient();
            string requestData;
            requestData = Microsoft.IdentityManagement.Samples.mySMSProvider.GetRequestData(userMobileNumber, message);
            byte[] postData = Encoding.ASCII.GetBytes(requestData);

            byte[] response = wc.UploadData(mySMSProvider.RequestURL, postData);
            string result = Encoding.ASCII.GetString(response);  // result contains the error text
            int returnValue = System.Convert.ToInt32(result.Substring(0, 6), NumberFormatInfo.InvariantInfo);
            return returnValue;
        }
        public static string GetRequestData(string mobile, string message)
        {
            string myrequestData;
            myrequestData = "password=" + "password123"
                 + "&hp=" + System.Web.HttpUtility.UrlEncode(mobile)
                 + "&smsmessage=" + System.Web.HttpUtility.UrlEncode(message);
            return myrequestData;
        }
    
    };
}



Jason


Viewing all articles
Browse latest Browse all 6944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>