1

ユーザーが自分のサービスに登録できるアプリを作成しようとしています。問題は、各ユーザーを非常に 1 つのアカウントに制限できることが非常に重要であることです。電話の一意の ID と Windows のライブ ID を使用してこれを実行できることがわかりました。アプリ内でこれらを取得する方法もわかりましたが、今、私の問題はそれらを私に届ける方法です!希望のユーザー名の電話IDを私のメールアドレスに送信する方法について誰か助けてもらえますか? ありがとうございました

編集

このコードを使用して、必要な値を取得します

public static class ExtendedPropertyHelper  
{  
    private static readonly int ANIDLength = 32;  
    private static readonly int ANIDOffset = 2;  
    public static string GetManufacturer()  
    {  
        string result = string.Empty;  
        object manufacturer;  
        if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))  
            result = manufacturer.ToString();  

        return result;  
    }  

    //Note: to get a result requires ID_CAP_IDENTITY_DEVICE  
    // to be added to the capabilities of the WMAppManifest  
    // this will then warn users in marketplace  
    public static byte[] GetDeviceUniqueID()  
    {  
        byte[] result = null;  
        object uniqueId;  
        if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))  
            result = (byte[])uniqueId;  

        return result;  
    }  

    // NOTE: to get a result requires ID_CAP_IDENTITY_USER  
    //  to be added to the capabilities of the WMAppManifest  
    // this will then warn users in marketplace  
    public static string GetWindowsLiveAnonymousID()  
    {  
        string result = string.Empty;  
        object anid;  
        if (UserExtendedProperties.TryGetValue("ANID", out anid))  
        {  
            if (anid != null && anid.ToString().Length >= (ANIDLength + ANIDOffset))  
            {  
                result = anid.ToString().Substring(ANIDOffset, ANIDLength);  
            }  
        }  

        return result;  
    }  
}  

今、私はthesを変数に保存する必要があります(実際には機能しません)。次に、それらを抽出するphpスクリプトに送信する必要があります

これに加えて、ユーザーにメールアドレスを入力してもらい、これも POST に含めるように依頼する必要があります。

4

2 に答える 2

0

「私のサービス」が Web サービスの場合、メール システムの代わりに Web サービスを使用できます。

いずれの場合も、Convert.ToBase64String(phoneId) を使用して電話 ID を文字列に変換できます。

WP7 からメールで文字列を送信するには、EmailComposeTask を使用する必要があります。

于 2012-09-12T12:03:42.933 に答える
0

名前空間DeviceExtendedProperties.DeviceUniqueId から取得できます。Microsoft.Phone.Infoで宣言することを忘れないでくださいWMAppManifest.xml

このような:

<Capabilities>
  <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
  <Capability Name="ID_CAP_IDENTITY_USER"/>
</Capabilities>

msdnへのリンクはこちら

次に、この ID を電子メールに送信できます。

var emailComposeTask = new EmailComposeTask
{
    To = "your-email@domiain.com",
    Subject = "Test Message using EmailComposeTask",
    Body = deviceId
};
emailComposeTask.Show();

しかし、これは電子メールクライアントを開きます。私は、そのユーザーがあなたに電子メールを送信するのにとても親切だとは思いません. したがって、サーバーに POST リクエストを送信することをお勧めします

     private void Button_Click(object sender, RoutedEventArgs e)
    {
        //collect all data you need:
        var deviceId = Convert.ToBase64String(ExtendedPropertyHelper.GetDeviceUniqueID());
        var userName = ExtendedPropertyHelper.GetWindowsLiveAnonymousID();
        var manufatcurer = ExtendedPropertyHelper.GetManufacturer();
        //create request string
        //[see the explanation on MSDN][2]
        var requestUrl = string
  .Format("http://myPageUrlAddress.com/script.aspx?deviceid={0}&user={1}&manufacturer={2}",
   deviceId, userName, manufatcurer);


        System.Uri myUri = new System.Uri(requestUrl);
        //create a request instance
        HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(myUri);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        //and it will be sent. 
        //Also you need to create GetRequestStreamCallback method to 
        //handle server responce.
        myRequest.BeginGetRequestStream(new
        AsyncCallback(GetRequestStreamCallback), myRequest);
    }
    //this method is empty. You can show tha dialog box about successful sending.
    public void GetRequestStreamCallback(IAsyncResult result) { ; }

電子メールについてはどうでしょうか。同じページに TextBox を作成し、ユーザー入力を変数に保存するだけです。

于 2012-09-12T12:04:03.103 に答える