Can I use /:user/:list_id/create_all.xml ?

Sep 23, 2010 at 3:21 AM

Hi

I'm trying to add more than one new member to a List ... and I cannot find the implementation of the http://api.twitter.com/version/:user/:list_id/create_all.xml  API call... 

See http://dev.twitter.com/doc/post/:user/:list_id/create_all

Is there a way that we can execute raw URLs that are not yet wrapped?

Thanks

Oliver

Sep 23, 2010 at 4:15 AM

Ok... I have added the function myself for the time-being... there's a bug in the API ...   You have to put the '/members/' before the "create_all.xml"

Lists are limited to 500 members and you can only add 100 at a time.  

        /// <summary>
        /// Adds a list of users to a list
        /// </summary>
        /// <param name="screenName">name of user to add member to list for</param>
        /// <param name="listID">ID or slug of list</param>
        /// <param name="membersID">comma separated list of IDs of members to add</param>
        /// <returns>List info for list member added to - up to 100 Members at a time can be added</returns>
        public virtual List AddMemberRangeToList(string screenName, string listID, string membersID)
        {
            if (string.IsNullOrEmpty(screenName))
            {
                throw new ArgumentException("screenName is required.", "screenName");
            }

            if (string.IsNullOrEmpty(listID))
            {
                throw new ArgumentException("listID is required.", "listID");
            }

            var savedSearchUrl = BaseUrl + screenName + "/" + listID + @"/members/create_all.xml";

            var resultsXml =
                TwitterExecutor.ExecuteTwitter(
                    savedSearchUrl,
                    new Dictionary<string, string>
                    {
                        { "user_id", membersID }
                    });

            List<List> results = new ListRequestProcessor<List>().ProcessResults(resultsXml);
            return results.FirstOrDefault();
        }

Coordinator
Sep 23, 2010 at 4:44 AM

Hi Oliver,

There are some newer additions to the API that I haven't added yet, but they are planned.  Your suggestion for executing raw URLs is interesting and is something that has crossed my mind on occasion.  The current implementation is based on a strategy on IRequestProcessor<T>'s; ListRequestProcessor for the list API.  I suppose it would be possible to add a UrlRequestProcessor with a fragment property that I could append to the base url in BuildUrl. Then the ProcessResponse could return an XElement.  It won't be as convenient as specific APIs, but it might keep people from getting stuck when the Twitter API changes or something new is added, as in your case.  What do you think?

Joe

Coordinator
Sep 23, 2010 at 4:47 AM

Thanks for the code; and the heads up on the bug.

Joe

Sep 23, 2010 at 5:14 AM

Hi Joe

You're welcome...  I've put my copy of the TwitterContext.cs in as a patch...  I had downloaded 2.0.12 yesterday..  so my copy is up-to-date?

Users of my software could be adding 100 or so members to a List... and it was vital to keep the api count down...  although neither calls are rate-limited according to the API docs...

Might it be too risky ... and it would have helped to test the API calls..  to have raw URL access... 

TwitterContext.CallURL (url, Dictionary<key,value>)  which would basically expose the TwitterExecute.ExecuteTwitter method?  But I understand the problem, that you then end up with an XElement ... unless the developer passes in the expected type...?  There's perhaps too much variance ... 

I haven't looked too deeply into it, as sunrise here is looming nearby...   I got stuck for some reason yesterday, 2.0.11 wasn't returning SocialGraph.Followers in my VB app... but SocialGraph.Friends worked fine... 2.0.12 works.  Then I couldn't get details on a list of user_ids (comma-separated) - found the answer in your blog (rather than codeplex) about the versioned BaseURL.  All running fine now... Well, apart from the fact I just discovered the GetListMembers function is only returning 20 members at a time...  That'll not take much to fix up... 

Regards

Oliver

 

Coordinator
Sep 26, 2010 at 5:22 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Oct 3, 2010 at 3:19 AM
JoeMayo wrote:

Hi Oliver,

There are some newer additions to the API that I haven't added yet, but they are planned.  Your suggestion for executing raw URLs is interesting and is something that has crossed my mind on occasion.  The current implementation is based on a strategy on IRequestProcessor<T>'s; ListRequestProcessor for the list API.  I suppose it would be possible to add a UrlRequestProcessor with a fragment property that I could append to the base url in BuildUrl. Then the ProcessResponse could return an XElement.  It won't be as convenient as specific APIs, but it might keep people from getting stuck when the Twitter API changes or something new is added, as in your case.  What do you think?

Joe

I acted on this today and checked in a new extensibility API that allows you to pass raw URLs and parameters to Twitter.  You use the RawQuery entity for queries and the ExecuteRaw method for side-effects.  There are examples in the LinqToTwitterDemo project, RawDemo.cs.

Joe

Oct 4, 2010 at 5:37 PM

I saw the Work Item update... So.. the Lists.. CreateAll function is in?   I'm working off a branched copy of LinqToTwitter so I'll have a peek ... and if so I'll change over to 2.0.14 ... 

thanks

Oliver