logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Login


Options
View
Go to last post Go to first unread
Eric  
#1 Posted : Tuesday, May 7, 2013 1:25:34 AM(UTC)
Eric

Rank: Newbie

Groups: Registered
Joined: 5/7/2013(UTC)
Posts: 2
Location: haha

Hi, I am wondering if I can get departures by sms code of stops right now just like sending sms to 35890. If I can, how can I do that? If not, will this be added? Thanks!
Ryan  
#2 Posted : Tuesday, May 7, 2013 7:23:18 AM(UTC)
Ryan

Rank: Administration

Groups: Administrators, Registered
Joined: 6/1/2011(UTC)
Posts: 88
United States
Location: Urbana

Thanks: 1 times
Was thanked: 6 time(s) in 6 post(s)
Hi Eric,

You can't directly get departures using an SMS code. This was an intentional decision and is unlikely to be added in the future. The SMS codes exist because of the limits of the SMS platform, but they are not the most user friendly. We prefer to downplay their prominence outside of the SMS usage and have people search by stop name or location.

That being said, if you have your heart set on using the SMS codes to resolve stops, it would be pretty easy to indirectly get departures by SMS code. Two ways come to mind. First, you could use GetStopsBySearch or our Autocomplete API both of which will let you search by SMS code. Then you can just pass the returned stop_id to GetDeparturesByStop as normal. The other way would be to use GetStops to get (and cache) a list of all stops and then implement your own search of the stops using the 'code' field.

I hope this makes sense and helps. Let us know if you have any other questions.

Ryan
Eric  
#3 Posted : Tuesday, May 7, 2013 10:21:15 PM(UTC)
Eric

Rank: Newbie

Groups: Registered
Joined: 5/7/2013(UTC)
Posts: 2
Location: haha

Ryan wrote:
Hi Eric,

You can't directly get departures using an SMS code. This was an intentional decision and is unlikely to be added in the future. The SMS codes exist because of the limits of the SMS platform, but they are not the most user friendly. We prefer to downplay their prominence outside of the SMS usage and have people search by stop name or location.

That being said, if you have your heart set on using the SMS codes to resolve stops, it would be pretty easy to indirectly get departures by SMS code. Two ways come to mind. First, you could use GetStopsBySearch or our Autocomplete API both of which will let you search by SMS code. Then you can just pass the returned stop_id to GetDeparturesByStop as normal. The other way would be to use GetStops to get (and cache) a list of all stops and then implement your own search of the stops using the 'code' field.

I hope this makes sense and helps. Let us know if you have any other questions.

Ryan


Hi, Ryan. Thanks for your reply. I did what you said yesterday and it worked! It is actually a more friendly and flexible way for users to search. So thanks a lot. But I got this new problem with method api. I am a python developer and use a library called urllib2 to make http request for the return values of the methods provided by mtd. The problem is that when I make a request if I don't include the last backslash '/' in the url(e.g http://developer.cumtd.com/api/v2.2/json/GetStop) it will be redirected to the url(http://developer.cumtd.com/api/v2.2/json/GetStop/), but urllib2 can't handle redirected url properly like a webbrowser does and gives http error 307. If I include the backslash in the url, it will show the error message "method isn't allowed". Probably because it recognize "GetStop/" as a method name. Do you have any ideas on it?
Ryan  
#4 Posted : Wednesday, May 8, 2013 7:41:41 AM(UTC)
Ryan

Rank: Administration

Groups: Administrators, Registered
Joined: 6/1/2011(UTC)
Posts: 88
United States
Location: Urbana

Thanks: 1 times
Was thanked: 6 time(s) in 6 post(s)
Hi Eric,

I'm glad to hear that you got the searching sorted out. Did you end up using the Autocomplete API or the regular GetStopsBySearch method?

So as far as the 307 redirect, i haven't been able to reproduce it. Loading GetStop in Chrome dev tools shows a normal '200 OK' status code. I'm not much of a Python developer, but this works in 3.3.1 (I used urllib.request which apparently replaced urllib2 in Python 3.x):

Code:
import urllib.request

key = 'YOUR_KEY'
stopId = 'it'

response = urllib.request.urlopen('http://developer.cumtd.com/api/v2.2/json/GetStop?key=' + key + '&stop_id=' + stopId)
json = response.read()

print (json.decode('utf-8'))


Anyway, can you give me some more info on how I can reproduce this behavior?

Ryan
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.