timelines.go
changeset 156 70aadba26338
parent 155 0c581e0108da
child 160 9f7e683b323f
equal deleted inserted replaced
155:0c581e0108da 156:70aadba26338
    15 
    15 
    16 // GetTimelines returns a timeline (a list of statuses
    16 // GetTimelines returns a timeline (a list of statuses
    17 // timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag")
    17 // timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag")
    18 // For the public timelines, you can set 'local' to true to get only the
    18 // For the public timelines, you can set 'local' to true to get only the
    19 // local instance.
    19 // local instance.
       
    20 // If lopt.All is true, several requests will be made until the API server
       
    21 // has nothing to return.
       
    22 // If lopt.Limit is set (and not All), several queries can be made until the
       
    23 // limit is reached.
    20 func (mc *Client) GetTimelines(timeline string, local bool, lopt *LimitParams) ([]Status, error) {
    24 func (mc *Client) GetTimelines(timeline string, local bool, lopt *LimitParams) ([]Status, error) {
    21 	var endPoint string
    25 	var endPoint string
    22 
    26 
    23 	switch {
    27 	switch {
    24 	case timeline == "home", timeline == "public":
    28 	case timeline == "home", timeline == "public":
    43 	if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &tl); err != nil {
    47 	if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &tl); err != nil {
    44 		return nil, err
    48 		return nil, err
    45 	}
    49 	}
    46 	if lopt != nil { // Fetch more pages to reach our limit
    50 	if lopt != nil { // Fetch more pages to reach our limit
    47 		var statusSlice []Status
    51 		var statusSlice []Status
    48 		for lopt.Limit > len(tl) && links.next != nil {
    52 		for (lopt.All || lopt.Limit > len(tl)) && links.next != nil {
    49 			newlopt := links.next
    53 			newlopt := links.next
    50 			links = apiLinks{}
    54 			links = apiLinks{}
    51 			if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil {
    55 			if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil {
    52 				return nil, err
    56 				return nil, err
    53 			}
    57 			}