Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

google api issue


  • Please log in to reply
5 replies to this topic

#1 mutsop

mutsop

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts

Posted 22 January 2012 - 04:00 PM

I'm not sure how I should name the title for this but here goes my problem:

So my first challenge with the n+ was to lit up a led whenever I get a new mail.

So a few issues goes thourgh my mind:
1- I suppose there is a limit amount of queries you can do in a certain amount of time... But how many?
2- I need an api key but where do I get it? I keep finding those for use with a domain name (which I don't have as its a standalone program)

So this is my code as for now:
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Xml;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using Google.GData.Client;

namespace GmailAlert
{
    public class Program
    {
        public static void Main()
        {
            string CONSUMER_KEY = "mydomain.com";
            string CONSUMER_SECRET = "my_consumer_secret";
            string TARGET_USER = "test_user";

            OAuth2LeggedAuthenticator auth = new OAuth2LeggedAuthenticator("GmailFeedReader", CONSUMER_KEY, CONSUMER_SECRET, TARGET_USER, CONSUMER_KEY);
            HttpWebRequest request = auth.CreateHttpWebRequest("GET", new Uri("https://mail.google.com/mail/feed/atom/"));
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

            XmlReader reader = XmlReader.Create(response.GetResponseStream());

            while (reader.Read())
            {
                Debug.Print(reader.Name);
            }
        }

    }
}

I still need to implement the code to get the number of the "fullamount" node. But as for now this is a test.

But as for the questions I tried expert-exchange forum and even the google groups and none have answered so far... Quite ironic if you ask me.

So I hope you guys could help me with that :)

Also if someone knew how to get the same result for hotmail (api) you'll get a cookie!
as the only things I seem to find info on is contacts, calendar, files... but no mails.

#2 mutsop

mutsop

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts

Posted 23 January 2012 - 12:45 PM

K so I'm one step further

This link might be of some help: http://stackoverflow...t-for-gmail-api

But it says something about HMAC-SHA1... So I checked and found this website:
http://code.google.c...ml#SigningOAuth

I quote:

Generate an oauth_signature using one of the following sequences:
If your application is not registered, select HMAC-SHA1 and use the following key and secret:
consumer key: "anonymous"
consumer secret: "anonymous"
If your application is registered and you're using RSA-SHA1, use the private key corresponding to the certificate uploaded to Google during registration.
If your application is registered and you're using HMAC-SHA1, use the OAuth "consumer secret" value generated during registration; this value is displayed on your domain's registration page.



"If your application is not registered, select HMAC-SHA1"

Where do I select HMAC-SHA1? What link should I go to?
I've read the whole page and nothing! Why is google being so unclear about this?

I hope someone can help me on this :)

#3 Geancarlo

Geancarlo

    Member

  • Members
  • PipPip
  • 24 posts

Posted 23 January 2012 - 03:26 PM

Hello, have you compiled the google api and executed any simple app using it for the netduino/.netmf without problems?

#4 mutsop

mutsop

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts

Posted 23 January 2012 - 05:46 PM

mmm now that you say I can't seem to compile it to the netduino :(

The type 'System.Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

The type 'System.Net.HttpWebRequest' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

The best overloaded method match for 'Google.GData.Client.Authenticator.CreateHttpWebRequest(string, System.Uri)' has some invalid arguments

Argument 2: cannot convert from 'System.Uri [c:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.Http.dll]' to 'System.Uri'


I guess I need to find another way :(


I did found another way but it's used for the full .net framework which is:
WebRequest request = HttpWebRequest.Create( new Uri( "https://mail.google.com/mail/feed/atom/" ) );

NetworkCredential networkCredential = new NetworkCredential( "myAccount@gmail.com", "myPWD" );
request.Credentials = networkCredential;

HttpWebResponse response = request.GetResponse( ) as HttpWebResponse;

System.IO.StreamReader reader = new System.IO.StreamReader( response.GetResponseStream( ) );

Problem though is that
request.Credentials doesn't exist and System.IO.StreamReader neither

#5 smarcus3

smarcus3

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts

Posted 09 April 2012 - 03:41 AM

I want to do the same thing any progress ???
Steve


My Other Hobby: Engineer Turned Baker

#6 novad

novad

    New Member

  • Members
  • Pip
  • 1 posts
  • LocationColombia

Posted 07 November 2012 - 07:30 AM

The thing is you're sending a request to https://mail.google.com/mail/feed/atom/
I've tried sending some request to some google services using the netduino but that always requires the use of https, which netduino doesn't support.

PD this thread is old, lol




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.