开发者

How to get responses other than timestamp and num_bytes from TripIt API?

开发者 https://www.devze.com 2023-02-20 08:48 出处:网络
I have got a successful oauth TripIt granting process using the same methodology that is used to connect and authenticate users against the LinkedIn and Twitter APIs in PHP (PECL Oauth etc).

I have got a successful oauth TripIt granting process using the same methodology that is used to connect and authenticate users against the LinkedIn and Twitter APIs in PHP (PECL Oauth etc).

However, whenever when I do a valid request (ie a 200 response... no 401 nor 404), all I get in response is:

<Response><timestamp>1301411027</timestamp><num_bytes>80</num_bytes></Response>

I want to list the authenticated user's profile and trip data... The API docs (the pdf) is a bit sketchy on how to do this when the actual user id isn't known, but here are the queries I have attempted: https://api.tripit.com/v1/list/trip ht开发者_如何学编程tps://api.tripit.com/v1/list/trip/traveler/true https://api.tripit.com/v1/get/profile

All returning the same response (as part of the oauth class "last response" method). This is where the LinkedIn API response contents can be found... so what is going on with TripIt? :P


It took a bit of experimenting, but here's an example of one that appears to be working to return data.

$response = $TripIt->_do_request('get/profile');

EDIT:

This one is likely the preferred method.

$response = $TripIt->_do_request('get', 'profile');

I've gone one step further and thrown it into an XML parser.

$response = $TripIt->_do_request('get', 'profile');
$profile = new SimpleXMLElement($response);

Here is one I'm using to get past trips. That third parameter is the one to use for filters.

$response = $TripIt->_do_request('list', 'trip', array('past'=>'true' );
$trips = new SimpleXMLElement($response);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号