Get User Name when requesting token

Jun 5, 2009 at 4:03 AM

Can you add "First Name" and "Last Name" to user?

Also could you add an xdocument element for the "raw" return? (useful to access new features not implemented)

Finally, is it possible to make direct calls?  If so, how.

PS, I am new to VB.net so please excuse elementary questions.

 

Jun 6, 2009 at 8:14 PM

Casey, thanks for your note.  It's not clear to me what you're asking for (I didn't write the code, and I'm only now getting familiar with some of the code as I try to add a few features & XML documentation), so I'd like to ask for some clarifications:

  • When you ask to add FN & LN to user, are you asking that the wrapNetflix (WNF) assembly return these data in some (unspecified) method that accesses some kind of user data?  Or are you looking for some way for some (unspecified) method to accept FN and/or LN as query parameters in a search for some kind of user data?
  • What does adding an xdocument element mean?  Do you want one of the methods to return data in a different format?
  • What does the "raw" return refer to?  Is that the output for one of the methods, or is it a subset of methods you're interested in?  If the latter, can you please specify the methods for which you would most like to see such an enhancement?
  • What do you mean by "direct calls"?

Please excuse my unfamiliarity with what you're asking about - I'm new to this codebase, so I guess that means we're even :)

Jun 8, 2009 at 4:55 AM
> Can you add "First Name" and "Last Name" to user?

I think that is reasonable.

> Also could you add an xdocument element for the "raw" return? (useful to
> access new features not implemented)

I don't quite understand your question, but perhaps the answer to the
next one will help.

> Finally, is it possible to make direct calls? If so, how.

The NetflixUrls module contains a bunch of functions that represent
all of the API calls you can make. Each function returns a RestCall
object with the appropriate parameters.

Once you have a RestObject, you can pass it to the NetflixConnection
object's RequestXmlResource method. This will add all the right
security information and send the request to Netflix.

The result can be returned as XML, a string, or as a raw stream. Most
of the time the XML version is what you want.

Jonathan


On Thu, Jun 4, 2009 at 8:03 PM, caseyd<notifications@codeplex.com> wrote:
> From: caseyd
>
> Can you add "First Name" and "Last Name" to user?
>
> Also could you add an xdocument element for the "raw" return? (useful to
> access new features not implemented)
>
> Finally, is it possible to make direct calls?  If so, how.
>
> PS, I am new to VB.net so please excuse elementary questions.
>
>
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Jun 8, 2009 at 5:15 AM
Caseyd,

I have added the FirstName/LastName property to the User class. You
will need to build the DEV branch yourself if you want to use it right
away. Check out the last few lines of User.vb, that will show you how
to make direct API calls.

Mike,

Go ahead and take a look at that code too. I think it is the cleanest
example of how to make calls using NetflixConnection and NetflixUrls,
everything else is just a wrapper around this.

Jonathan


On Sat, Jun 6, 2009 at 12:14 PM, MikeSL <notifications@codeplex.com> wrote:
>
> From: MikeSL
>
> Casey, thanks for your note.  It's not clear to me what you're asking for (I didn't write the code, and I'm only now getting familiar with some of the code as I try to add a few features & XML documentation), so I'd like to ask for some clarifications:
>
> When you ask to add FN & LN to user, are you asking that the wrapNetflix (WNF) assembly return these data in some (unspecified) method that accesses some kind of user data?  Or are you looking for some way for some (unspecified) method to accept FN and/or LN as query parameters in a search for some kind of user data?
> What does adding an xdocument element mean?  Do you want one of the methods to return data in a different format?
> What does the "raw" return refer to?  Is that the output for one of the methods, or is it a subset of methods you're interested in?  If the latter, can you please specify the methods for which you would most like to see such an enhancement?
> What do you mean by "direct calls"?
>
> Please excuse my unfamiliarity with what you're asking about - I'm new to this codebase, so I guess that means we're even :)
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email ([email removed])
>
> To start a new discussion for this project, email [email removed]
>
> You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
Jun 8, 2009 at 6:33 AM

Sorry about some of the confusion.  Part of this is because this is my first attempt at a VB.Net app.  I have used VBA in the past, but, this is a learning experience for me.

I guess what I meant to ask for is to add two properties to the User class.  In the NetFlix API, "User"  ( http://api.netflix.com/users/12345678), contains the First Name and Last Name of the account.  It also has some other useful information (such as if IW is allowed)as well.  I would like to see new Properties added to the WrapNetflix.User class for "First_Name" and "Last_Name".  There are a few other bits of information there that others might find useful (such as IW availability) that might also be added.

This is how I am currently getting the information had to make a seperate call:          

  Users = con.RequestXmlResource(NetflixUrls.GetUsers(access), access)
  UserName = Users.<first_name>(0).Value & " " & Users.<last_name>(0).Value

I was thinking if an additional property is added for the raw "NetflixApi/User" feed is added as an xElement (not xdocument), then, as the NetFlix API is expanded, the additional information could be accessed through the wrapnetflix user class instead of making a direct REST call to the NetFlix API.

Plus, a "bug" that you might be able to help with (not really a bug, but, an issue).  The NetFlix API has a 4 call per second limit.  Normally, this should not be a problem.  However, my project requires clearing and reloading the Queue.  There is no "bulk" delete or load yet (although it is supposed to be in the works).  To prevent this from causing a 403 exception, I wrote with this class:

Public Class ClsPause
    Dim Times(10) As DateTime
    Dim Calls As Integer
    Dim Calls_Per_Sec As Integer
    Public Sub New()
        Calls = 0
        Calls_Per_Sec = 4
        For Each el In Times
            el = DateAdd(DateInterval.Second, -1, Now)
        Next
    End Sub
    Public Property CallsPerSecond() As Integer
        Get
            CallsPerSecond = Calls_Per_Sec
        End Get
        Set(ByVal value As Integer)
            Calls_Per_Sec = value
        End Set
    End Property
    Public Property CallsMade() As Integer
        Get
            CallsMade = Calls
        End Get
        Set(ByVal value As Integer)
            Calls = value
        End Set
    End Property
    Public Sub CallWait()
        Calls += 1
        Dim LastnCalls = Times(Calls Mod Calls_Per_Sec)
        Dim runLength As Global.System.TimeSpan = Now.Subtract(LastnCalls)
        Dim millisecs As Integer = runLength.Milliseconds
        If millisecs < 1000 And Calls > Calls_Per_Sec Then
            System.Threading.Thread.Sleep(1000 - millisecs + 1)
        End If
        Times(Calls Mod Calls_Per_Sec) = Now
    End Sub
End Class

I use it my calling "CallWait()" before every call in my loops.  It "should" prevent making more then 4 calls per second by forcing a delay from the 5+ call equal to: 1_second - (time_of_nth_call - time_of_nth-4_call).  I am sure there is a better way to do it, but, it appears to work.  I added properties to change the CallsPerSecondAllowed and TotalCalls made, but, I haven't used them (or tested them) yet in my project.

If this could be incorporated directly into the wrapnetflix user class, then the end user (of the wrapnetflix api) would not have to worry about it.  The only "bug" I have with it is the class is not aware of other API calls being made.  I was still getting a 403 exception until I put a one second delay before the loop started.  Then, all seemed to work fine.  If added inside the wrapnetflix api, then it should never fail.

I am using the "free" express version which appears to be unable to work with this project (I think it is missing the class designer), so I can't play with the API myself.

Thanks for your help.  Again, accept my apologys if I am using the wrong terms.

CaseyD

Jun 8, 2009 at 6:45 AM
Edited Jun 8, 2009 at 6:59 AM

Grauenwolf -

Thanks for the reply.  I didn't see it before making the last post (forgot to hit the post your reply button for a little while).

>The NetflixUrls module contains a bunch of functions that represent
all of the API calls you can make. Each function returns a RestCall
object with the appropriate parameters.

Then it looks like I was doing it the correct way... 

 I will attempt to build the project again tomorrow and change my code to use the new properties.  (I get a lot of errors about solutions folders not being available, but it looks like I was able to build it for my device.).

Also, if there is a better way to accomplish the "limit 4 calls per second", again let me know.

Thanks again!

CaseyD

Jun 8, 2009 at 3:32 PM
I have added a new property called MinDelay. If you set this, it will
ensure at least X time passes between each call.

Attached is a preview of the new build. Please test and let me know if
it works for you.

Jonathan

On Sun, Jun 7, 2009 at 10:45 PM, caseyd<notifications@codeplex.com> wrote:
> From: caseyd
>
> Grauenwolf -
>
> Thanks for the reply.  I didn't see it before making the last post (forgot
> to hit the post your reply button for a little while).
>
>>The NetflixUrls module contains a bunch of functions that represent
> all of the API calls you can make. Each function returns a RestCall
> object with the appropriate parameters.
>
> Then it looks like I was doing it the correct way...  I will attempt to
> build the project again tomorrow.  But, I don't think I will be able to with
> the express version.  If there is a way, please let me know.
>
> Also, if there is a better way to accomplish the "limit 4 calls per second",
> again let me know.
>
> Thanks again!
>
> CaseyD
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Jun 8, 2009 at 5:01 PM

Thanks again! 

I took a quick peek at the code and it looks like it should work great.  I will likely set min delay to 250ms which should prevent more then 4 calls per second.  I guess I was trying to get way too complicated.  Now that I think about it, this method would rarely cause any unneeded delay.

One suggestion I have is you might want to set the default to 250ms so others will not get burned by the 4 seconds per call (took me a while hours to figure it out).


Thanks again,

CaseyD

 

 

 

Jun 8, 2009 at 6:28 PM
I'm not ready to do that quite yet.

I would rather it catch the error and automatically retry, but that
requires a much better understanding of how the API works.

Jonathan

On Mon, Jun 8, 2009 at 9:01 AM, caseyd<notifications@codeplex.com> wrote:
> From: caseyd
>
> Thanks again!
>
> I took a quick peek at the code and it looks like it should work great.  I
> will likely set min delay to 250ms which should prevent more then 4 calls
> per second.  I guess I was trying to get way too complicated.  Now that I
> think about it, this method would rarely cause any unneeded delay.
>
> One suggestion I have is you might want to set the default to 250ms so
> others will not get burned by the 4 seconds per call (took me a while hours
> to figure it out).
>
> Thanks again,
>
> CaseyD
>
>
>
>
Jun 9, 2009 at 12:41 AM
Not to mention a more clearly documented, and more explicitly
supported, API. I get the impression that Netflulix has left open the
possibility to change the API implementation anytime they like, and
that those who have developed apps against the current API will just
be out of luck (i.e. have to just rewrite their code).
Jun 9, 2009 at 3:28 AM

> I would rather it catch the error and automatically retry, but that
> requires a much better understanding of how the API works.

I was thinking the same thing about the automatic retry for 403 errors, but, I have since changed my mind.  I am sure this limit was imposed to keep NetFlix servers from getting overloaded.  I have herd people get notices from NetFlix when they violate the calls per second/day, although I didn't get any yet myself.  I view the 403 error as my (developer) error, and not an app user error.  If you made the API to automatically retry for 403 errors, it would hide a potential problem from the developer.  From looking at the NetFlix blog, it seems that when someone hits one of these limits, that there is usually a better way to do what they are trying to do anyways.  Once the bulk queue upload calls are released, I too will have a better way to do what I am trying to do.  If there was a serious bug that caused many excessive API calls, NetFlix might get mad and block a key or send unexpected letters to the developer.

 

 

 

Jun 9, 2009 at 5:00 AM
I agree with you on both points.

Jonathan

On Mon, Jun 8, 2009 at 4:41 PM, MikeSL<notifications@codeplex.com> wrote:
> From: MikeSL
>
> Not to mention a more clearly documented, and more explicitly
> supported, API. I get the impression that Netflulix has left open the
> possibility to change the API implementation anytime they like, and
> that those who have developed apps against the current API will just
> be out of luck (i.e. have to just rewrite their code).
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Jun 9, 2009 at 5:02 AM
That's news to me. Last time I hit a threshold I didn't get an email.
Instead, they cut me off and every request was something about not
getting access for 24 hours.

Of course I was doing something bad. Specificially, downloading the
full details for every movie in the index.

Jonathan

On Mon, Jun 8, 2009 at 7:28 PM, CaseyD<notifications@codeplex.com> wrote:
> From: CaseyD
>
>> I would rather it catch the error and automatically retry, but that
>> requires a much better understanding of how the API works.
>
> I was thinking the same thing about the automatic retry for 403 errors, but,
> I have since changed my mind.  I am sure this limit was imposed to keep
> NetFlix servers from getting overloaded.  I have herd people get notices
> from NetFlix when they violate the calls per second/day, although I didn't
> get any yet myself.  I view the 403 error as my (developer) error, and not
> an app user error.  If you made the API to automatically retry for 403
> errors, it would hide a potential problem from the developer.  From looking
> at the NetFlix blog, it seems that when someone hits one of these limits,
> that there is usually a better way to do what they are trying to do
> anyways.  Once the bulk queue upload calls are released, I too will have a
> better way to do what I am trying to do.  If there was a serious bug that
> caused many excessive API calls, NetFlix might get mad and block a key or
> send unexpected letters to the developer.
>
>
>
>
>
>
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com