Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a URL for generating Microsoft Tags for Windows Phone 7 Apps?

I'm developing a web site that will feature windows phone 7 apps, and I'd like to include a Microsoft Tag so users can point their phone at the screen and download the app that is featured.

So far their website has proven to be quite unhelpful, and it seems you need to sign up for the API if you don't want to generate them all manually.

I was wondering if there is a single URL that I can place the app ID into, hosted on Microsoft's servers, that will generate the tag for me?

like image 312
Ben Cull Avatar asked May 23 '11 00:05

Ben Cull


1 Answers

There isn't just one URL that will create a tag for you. But this being Stack Overflow, here's a short program that uses the Tag API to create any number of tags. For the program to work, you will need to:

  1. add a service reference to the Tag API at https://ws.tag.microsoft.com/MIBPService.wsdl
  2. Make sure to insert your own Tag API key into creds.AccessToken.
  3. Increase the maxArrayLength="16384" value in app.config to something higher. This is needed to pull the ~45KB tag images from the web service. I used 100000.

The complete blog post is at http://flyingpies.wordpress.com/2011/05/25/creating-several-microsoft-tags/.

using System;
using System.IO;
using MakeTags.Tag;

namespace MakeTags {
    class Program {
        static void Main(string[] args) {
            MIBPContractClient tagService = new MIBPContractClient();
            UserCredential creds = new UserCredential();
            creds.AccessToken = "your-access-token-here";

            int tagsToCreate = 10;
            string category = "Main";
            string tagTitlePrefix = "My Sample Tag ";
            string tagImageFilePathFormat = "mytag{0}.png";

            for (int i = 0; i < tagsToCreate; ++i) {
                Console.WriteLine("Creating tag " + i);

                string tagTitle = tagTitlePrefix + i;

                URITag tag = new URITag();
                tag.Title = tagTitle;
                tag.MedFiUrl = "http://flyingpies.wordpress.com/2011/05/24/creating-several-microsoft-tags";
                tag.UTCStartDate = DateTime.UtcNow;
                tagService.CreateTag(creds, category, tag);

                string tagImageFilePath = string.Format(tagImageFilePathFormat, i);
                byte[] tagImageBytes = tagService.GetBarcode(
                    creds,
                    category,
                    tagTitle,
                    ImageTypes.png,
                    1f,
                    DecorationType.HCCBRP_DECORATION_DOWNLOAD,
                    false);
                File.WriteAllBytes(tagImageFilePath, tagImageBytes);
            }
        }
    }
}
like image 136
Oren Trutner Avatar answered Oct 20 '22 22:10

Oren Trutner