Windows phone 7 以电子邮件形式发送唯一的电话id
我尝试创建一个应用程序,允许用户注册我的服务。 问题是,我可以将每个用户限制为一个非常重要的帐户 我想我可以用手机的唯一id和windows live id来实现这一点 我也知道如何在应用程序中获取这些,但现在我的问题是如何将它们传递给我! 有人能帮我把带有所需用户名的电话号码发送到我的电子邮件地址吗? 多谢各位 编辑 我使用此代码获取所需的值Windows phone 7 以电子邮件形式发送唯一的电话id,windows-phone-7,Windows Phone 7,我尝试创建一个应用程序,允许用户注册我的服务。 问题是,我可以将每个用户限制为一个非常重要的帐户 我想我可以用手机的唯一id和windows live id来实现这一点 我也知道如何在应用程序中获取这些,但现在我的问题是如何将它们传递给我! 有人能帮我把带有所需用户名的电话号码发送到我的电子邮件地址吗? 多谢各位 编辑 我使用此代码获取所需的值 public static class ExtendedPropertyHelper { private static readonly
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;
}
}
现在,我需要将这些变量存储在我无法真正使用的变量中,然后将它们发送到我的php脚本中,由php脚本提取它们
除此之外,我需要要求用户输入他的电子邮件地址,并将其包含在帖子中,
您能帮忙吗?如果我的服务是web服务,那么您可以使用web服务而不是邮件系统 在这两种情况下,您都可以使用Convert.ToBase64StringphoneId将电话id转换为字符串 要通过邮件从WP7发送字符串,您需要使用EmailComposetTask。您可以从Microsoft.Phone.Info命名空间获取DeviceExtendedProperties.DeviceUniqueId。 不要忘记在WMAppManifest.xml中声明 像这样:
<Capabilities>
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
<Capability Name="ID_CAP_IDENTITY_USER"/>
</Capabilities>
但这将打开一个电子邮件客户端,我不认为用户会如此好心地向您发送电子邮件。因此,您最好向服务器发送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) { ; }
电子邮件呢?只需在同一页面上创建一个文本框,并将用户输入保存到一个变量中
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) { ; }