Search code examples
silverlightbing-apigoogle-search-api

How to pass a search term to Bing from silverlight or google


Has anyone had any luck passing from Silverlight to Bing or Google a url parameter based string that will open search results in a browser. I have been using the Bing API and been able to search and return results within the client and I have also done this using JSON and passing values to the Google API. However if you want to just send a query string to either service and have the results returned via a browser result list I have not found this to be possible. What I am trying to see if it is possible to pass a term "gocart" to Google or Bing as a url (http:www.bing.com/query?gocart) and it return in a new browser window results of the search term. From my initial research both search engines appear to prevent unauthorized queries via URL, I was curious if anyone found it different.

thanks


Solution

  • I have made a hyperlink class:

    private class HyperlinkButtonWrapper : HyperlinkButton
    {
        public void OpenURL(string navigateUri)
        {
            OpenURL(new Uri(navigateUri, UriKind.Absolute));
        }
    
        public void OpenURL(Uri navigateUri)
        {
            base.NavigateUri = navigateUri;
            base.TargetName = "_blank";
            base.OnClick();
        }
    }
    

    Then use it like this:

    private void ButtonSearch_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        var hyperlinkwrapper = new HyperlinkButtonWrapper();
        hyperlinkwrapper.OpenURL(@"http://www.google.com/#q=gocart");
    
    }
    

    I found that on this blog