Page 1 of 1

Requesting 10 capabilities, only 2 being returned

Posted: Wed Sep 17, 2014 12:30 pm
by ManFromBozrah
Hello,
I wrote .net 2.0 code to request the following capabilities when calling GetDeviceInfo

model_name,brand_name,is_smartphone,is_tablet,is_wireless_device,resolution_width,resolution_height,max_image_width,max_image_height

Unfortunately, the only capabilities returned are

is_wireless and is_smartphone

What am I doing wrong? I get only these 2 capabilities when requesting from a desktop browser, ipad, and Android smartphone.

Re: Requesting 10 capabilities, only 2 being returned

Posted: Wed Sep 17, 2014 12:40 pm
by sm_support2
Hi, can you expand and post some code? ideally a self contained example. This would make it simpler for the support team to understand what is wrong.

Thanks

Re: Requesting 10 capabilities, only 2 being returned

Posted: Wed Sep 17, 2014 1:08 pm
by ManFromBozrah
The code below illustrates the issue where I'm only getting back the two capabilities. Obviously I haven't included my apikey (standard level).

Code: Select all

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import namespace="System" %>
<%@ Import namespace="System.Collections.Generic" %>
<%@ Import namespace="System.Configuration" %>
<%@ Import namespace="System.IO" %>
<%@ Import namespace="System.Text" %>
<%@ Import namespace="System.Xml" %>
<%@ Import namespace="ScientiaMobile.WurflCloud" %>
<%@ Import namespace="ScientiaMobile.WurflCloud.Config" %>
<%@ Import namespace="ScientiaMobile.WurflCloud.Http" %>

<script runat="server">
	XmlDocument xmlDoc;
    protected void Page_Load(object sender, EventArgs e)
    {

        xmlDoc = BrowserDetection();


    }
	public class DeviceInfoViewModel
	{
		public String UserAgent { get; set; }
		public String ServerVersion { get; set; }
		public String Library { get; set; }
		public String DeviceId { get; set; }
		public String DateOfRequest { get; set; }
		public String CachingModule { get; set; }
		public ResponseType Source { get; set; }
		public IDictionary<String, String> Capabilities { get; set; }
		public IDictionary<String, String> Errors { get; set; }
	}


	public const String WurflManagerCacheKey = "__WurflManager";
	private WurflService _service;

	string strScientiaApiKey = ConfigurationManager.AppSettings["ScientiaAPIKey"].ToString();

	public XmlDocument BrowserDetection()
	{
		_service = new WurflService();
		var Model = _service.GetDataByRequest(HttpContext.Current);

		StringBuilder sb = new StringBuilder();
		XmlWriterSettings settings = new XmlWriterSettings();
		XmlWriter writer = XmlWriter.Create(sb, settings);

		writer.WriteStartDocument();
		writer.WriteStartElement("BrowserDetection");
		writer.WriteElementString("UserAgent", HttpContext.Current.Request.UserAgent.ToLower());
		foreach (KeyValuePair<string, string> kvp in Model.Capabilities)
		{
			writer.WriteElementString(kvp.Key, kvp.Value);
			
		}
		writer.WriteEndElement();
		writer.WriteEndDocument();
		writer.Flush();

		XmlDocument doc = new XmlDocument();
		doc.LoadXml(sb.ToString());
		return doc;       
	}

	public class WurflService
	{
		string strScientiaApiKey = ConfigurationManager.AppSettings["ScientiaAPIKey"].ToString();
		public DeviceInfoViewModel GetDataByRequest(HttpContext context)
			{
				var config = new DefaultCloudClientConfig
				{

					ApiKey = strScientiaApiKey
				};

				var manager = new CloudClientManager(config);
				var info = manager.GetDeviceInfo(context, new [] {"model_name","brand_name","is_smartphone","is_tablet","is_wireless_device","resolution_width","resolution_height","max_image_width","max_image_height"});
				var model = new DeviceInfoViewModel
								{
									DeviceId = info.Id,
									ServerVersion = info.ServerVersion,
									DateOfRequest = info.WurflLastUpdate.ToString(),
									Library = manager.GetClientVersion(),
									Capabilities = info.Capabilities,
									Errors = info.Errors,
									Source = info.ResponseOrigin
								};

				return model;
			}
	}

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body style="font-family: Arial">

<form id="form1" runat="server">
	<% =xmlDoc.OuterXml %>
</form>
</body>

Re: Requesting 10 capabilities, only 2 being returned

Posted: Wed Sep 17, 2014 1:19 pm
by ManFromBozrah
It was a caching issue. Never mind. I'm sorry to have wasted your time with this.

Re: Requesting 10 capabilities, only 2 being returned

Posted: Wed Sep 17, 2014 1:26 pm
by Elliotfehr
Hello,

From what I can see, the capabilities have not been selected in your account on scientiamobile.com. Here are some instructions on how to add the capabilities to be retrieved from the cloud service.

Thank you,

Elliot