I'm not sure why the query object is returning NULL.  That's unusal,
esp. since you're not able to reproduce this problem.  Have you tried
using a fresh Google Account?

I noticed you're using 
https://www.google.com/h9/feeds/profile/default/-/medication
for the query.  Is this a cut and paste mistake.  For /health, the
query should be:

https://www.google.com/health/feeds/profile/default/-/medication

Regarding packet capture:
Checkout the article at 
http://code.google.com/apis/gdata/articles/wireshark.html.
I would use that to verify you're sending and receiving the correct
XML

Eric

On Oct 21, 11:26 am, unggoi <[EMAIL PROTECTED]> wrote:
> 3.) Can you post a packet capture of the request/response?
>
> Where/How can I check this, we use a different machine for our live
> site
>
> On Oct 20, 5:48 pm, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
>
> > Can you provide some context for the the service
> > and query objects?  It's possible your query and/or
> > service are not set correctly.
>
> > Here's a snippet that worked for me:
>
> > try {
> >   HealthQuery profileQuery = new HealthQuery("https://www.google.com/
> > health/feeds/profile/default");
> >   profileQuery.Digest = true;
>
> >   HealthFeed feed = service.Query(profileQuery);
>
> >   foreach (HealthEntry entry in feed.Entries)
> >   {
> >     // TODO
> >   }
> > catch (GDataRequestException e)
> > {
> >   // print the execption message
>
> > }
>
> > 1.) I would wrap your query code in the try/catch
> > 2.) Consider using the .NET library's HealthQuery, HealthFeed,
> > and HealthEntry instead of the generic Atom versions.
> > 3.) Can you post a packet capture of the request/response?
>
> > You could also try testing with ClientLogin (instead of AuthSub
> > tokens)
> > to confirm this is not a token exchange issue:
>
> > HealthService service = new HealthService("exampleCo-exampleApp-1");
> > service.setUserCredentials("email", "password");
>
> > Eric
>
> > On Oct 20, 12:21 pm, unggoi <[EMAIL PROTECTED]> wrote:
>
> > > Okay I found out the exact error message the service.query(query)
> > > returned a null or incorrect data.
> > > Error msg: System.NullReferenceException: Object reference not set to
> > > an instance of an object.
>
> > > Heres my code snippet and this is happening on /health. requesting of
> > > token is good but once I do the query the service returns an incorrect
> > > data or no data at all and caused the error. The weird thing is this
> > > problem is very hard to replicate, I myself can't replicate it  and
> > > most of the time it retuns the correct data. Except for the one person
> > > on the google healthservices team, they're getting mixed results
> > > there, others can't even replicate it.  What is causing this problem?
>
> > > AtomFeed healthFeed = service.Query(query);
> > > foreach (AtomEntry entry in healthFeed.Entries) <---caused the error
> > > because healthfeed is null
>
> > > pls help.
>
> > > On Oct 15, 12:26 pm, "Eric (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > On Oct 15, 11:38 am, "MWW Code" <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Eric,
> > > > > So my client was asking if thiserror"Invalid Usage, Sharing denied:
> > > > > unregistered provider." was caused by that non-registration.
> > > > > Could you confirm?
> > > > > I'll also paste my code so you may check if I missed something.
>
> > > > > <?
> > > > > function getAuthSubUrl()
> > > > > {
> > > > >   $next = getCurrentUrl();
> > > > >   $scope = 
> > > > > 'https://www.google.com/health/feeds/';#scope:https://www.google.com/h...
> > > > >   $authSubHandler = 'https://www.google.com/health/authsub';
> > > > >   $secure = 1;
> > > > >   $session= 1;
> > > > >   return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, 
> > > > > $secure,
> > > > > $session, $authSubHandler);
>
> > > > > }
>
> > > > You should still be using all /h9 URLs (unless you've been approved to
> > > > use /health).
> > > > But from what you've mentioned, it sounds like your domains have been
> > > > registered for /h9.  Being whitelisted for /health is the final step
> > > > for integration.
> > > > So:
> > > > $authSubHandler=khttps://www.google.com/h9/authsub
> > > > $scope=https://www.google.com/h9/feeds/
>
> > > > > function requestUserLogin($linkText)
> > > > > {
> > > > >   $authSubUrl = getAuthSubUrl();
> > > > >   $authSubUrl = str_replace("/accounts/AuthSubRequest", 
> > > > > "/health/authsub",
> > > > > $authSubUrl); #makes the AuthSub path 
> > > > > to:https://www.google.com/health/authsub
>
> > > > >   $authSubUrl = $authSubUrl . "&permission=1";
> > > > >   return "<a href=\"{$authSubUrl}\">{$linkText}</a>";
>
> > > > > }
>
> > > > > function getAuthSubHttpClient()
> > > > > {
> > > > >   global $_SESSION, $_GET;
>
> > > > >   $client = new Zend_Http_Client();
>
> > > > Use this new: Zend_Gdata_HttpClient();
>
> > > > >   // This sets your private key to be used to sign subsequent requests
> > > > >   $client->setAuthSubPrivateKeyFile('parsakey.pem', null, true);   # 
> > > > > --
> > > > > parsakey.pem is in the same directory as the calling page
> > > > >   $sessionToken =
> > > > > Zend_Gdata_AuthSub::getAuthSubSessionToken(trim($_GET['token']), 
> > > > > $client);
>
> > > > >   // Set the long-livedsessiontokenfor subsequent requests
> > > > >   $client->setAuthSubToken($sessionToken);
> > > > >   return $client;
>
> > > > > }
>
> > > > > // The calling page
>
> > > > > # :
> > > > > # :
> > > > > # :
> > > > >    else {
> > > > >      try{
> > > > >        $client         = getAuthSubHttpClient();
>
> > > > >        $healthService  = new Zend_Gdata($client);
> > > > > # :
> > > > > # :
> > > > > # :
> > > > > ?>
>
> > > > > On Wed, Oct 15, 2008 at 11:22 AM, Eric (Google) <[EMAIL PROTECTED]> 
> > > > > wrote:
>
> > > > > > On Oct 14, 3:25 pm, "MWW Code" <[EMAIL PROTECTED]> wrote:
> > > > > > > Hi Eric,
> > > > > > > Sorry for the nag, but I tried to make it happen like on the 
> > > > > > > sample you
> > > > > > gave
> > > > > > > me, and then now I get a "Invalid Usage, Sharing denied: 
> > > > > > > unregistered
> > > > > > > provider.". I'm actually aware that its a registration thing with 
> > > > > > > Google
> > > > > > > Health, yet someone from Google already asked us about which 
> > > > > > > domains to
> > > > > > > register. I just wanna confirm if this might be anerrorcause by a
> > > > > > possibly
> > > > > > > not registering to Google Health.
>
> > > > > > Yes.  It can take up to a week for the domain registrations to be
> > > > > > updated.
> > > > > > If you've received an email, then it shouldn't be long :)
>
> > > > > > Eric
>
> > > > > > > Thanks again.
>
> > > > > > > On Sat, Oct 11, 2008 at 6:33 AM, Eric (Google) <[EMAIL PROTECTED]>
> > > > > > wrote:
>
> > > > > > > > The Authorization header is slightly more complex
> > > > > > > > for secure=1 than secure=0 tokens:
> > > > > > > >http://code.google.com/apis/health/developers_guide_protocol.html#Aut.
> > > > > > ..
>
> > > > > > > > In short, you need to create a private key and public 
> > > > > > > > certificate
> > > > > > > > to sign requests.  Refer to the steps here for registration:
> > > > > > > >http://code.google.com/apis/health/getting_started.html#DomainRegistr.
> > > > > > ..
>
> > > > > > > > and here's code for using AuthSub with secure=1:
>
> > > > > > > >http://gdatatips.blogspot.com/2008/09/secure-authsub-using-zend-php-l.
> > > > > > ..
>
> > > > > > > > Eric
>
> > > > > > > > On Oct 10, 3:17 pm, "MWW Code" <[EMAIL PROTECTED]> wrote:
> > > > > > > > > Hi Eric,
>
> > > > > > > > > Its been quite a while since I wrote and seems that I really 
> > > > > > > > > need
> > > > > > your
> > > > > > > > help.
> > > > > > > > > I have the same problem. Things are running good for our 
> > > > > > > > > Google
> > > > > > Health
> > > > > > > > app
> > > > > > > > > with secure=0, but with secure=1 I get anError:Tokenupgrade
> > > > > > failed.
> > > > > > > > > Reason: Invalid AuthSub header.Error401.
>
> > > > > > > > > I haven't changed my code since then til we need to use 
> > > > > > > > > secure=1 that
> > > > > > I
> > > > > > > > > found it ain't pushing through.
>
> > > > > > > > > Code is as follows:
>
> > > > > > > > > function getAuthSubUrl()
> > > > > > > > > {
> > > > > > > > >   $next = getCurrentUrl();
> > > > > > > > >   $scope = "https://www.google.com/h9/feeds";; # uncomment upon
> > > > > > > > deployment
> > > > > > > > >   $secure = 1;
> > > > > > > > >   $session= 1;
> > > > > > > > >   return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope,
> > > > > > $secure,
> > > > > > > > >       $session);
>
> > > > > > > > > }
>
> > > > > > > > > function requestUserLogin($linkText)
> > > > > > > > > {
> > > > > > > > >   $authSubUrl = getAuthSubUrl();
> > > > > > > > >   $authSubUrl = str_replace("/accounts/AuthSubRequest",
> > > > > > "/h9/authsub",
> > > > > > > > > $authSubUrl);
> > > > > > > > >   $authSubUrl = $authSubUrl . "&permission=1";
> > > > > > > > >   return "<a href=\"{$authSubUrl}\">{$linkText}</a>";
>
> > > > > > > > > }
>
> > > > > > > > > function getAuthSubHttpClient()
> > > > > > > > > {
> > > > > > > > >   global $_SESSION, $_GET;
> > > > > > > > >   if (!isset($_SESSION['sessionToken']) && 
> > > > > > > > > isset($_GET['token'])) {
> > > > > > > > >     $_SESSION['sessionToken'] =
> > > > > > > > > Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], 
> > > > > > > > > null, "
> > > > > > > >https://www.google.com/accounts/AuthSubSessionToken";); //* <-- 
> > > > > > > >code
> > > > > > gets
> > > > > > > > > preempted here*
> > > > > > > > >   }
> > > > > > > > >   $client =
> > > > > > Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);
> > > > > > > > >   return $client;
>
> > > > > > > > > }
>
> > > > > > > > > // the executing code is:
>
> > > > > > > > > try{
> > > > > > > > >        $client         = getAuthSubHttpClient();
> > > > > > > > >        $healthService  = new Zend_Gdata($client);
>
> > > > > > > > >        $profileFeedUri = '
> > > > > > > >https://www.google.com/h9/feeds/profile/default?digest=true';
> > > > > > > > >        $query          = new 
> > > > > > > > > Zend_Gdata_Query($profileFeedUri);
>
> > > > > > > > >        $feed           = $healthService->getFeed($query);- 
> > > > > > > > > Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Health Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/googlehealthdevelopers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to