[twitter-dev] understanding data returned in arrays.

2010-09-07 Thread Bob Aiello
Hi everyone,

I am struggling a bit to find the right API reference that explains
how to work with the data that is returned from an expression like
$content = $connection-get('friends/ids', array('screen_name' =
'bobaiello'));

where get is shown below (as in Abraham William's excellent examples).

I am struggling with understanding:
1. how to parse the array returned in $connection
2. how to implement a curser to get the next batch of responses
(twitter seems to give me the first thousand only)
3. is the array one dimensional or a more complex structure (print_r
leads me to believe the latter)

any help or pointing me in the right direction would be greatly
appreciated.


Bob
http://www.linkedin.com/in/BobAiello
twitter: bobaiello, cmbestpractices, yellowspiderinc

  /**
   * GET wrapper for oAuthRequest.
   */
  function get($url, $parameters = array()) {
$response = $this-oAuthRequest($url, 'GET', $parameters);
echo mytest =.$response;
if ($this-format === 'json'  $this-decode_json) {
  return json_decode($response);
}
return $response;
  }

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


Re: [twitter-dev] understanding data returned in arrays.

2010-09-07 Thread Abraham Williams
Answers inline.

Abraham
-
Abraham Williams | Hacker Advocate | http://abrah.am
@abraham | http://projects.abrah.am | http://blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.


On Tue, Sep 7, 2010 at 07:13, Bob Aiello robertjaie...@gmail.com wrote:

 Hi everyone,

 I am struggling a bit to find the right API reference that explains
 how to work with the data that is returned from an expression like
 $content = $connection-get('friends/ids', array('screen_name' =
 'bobaiello'));

 where get is shown below (as in Abraham William's excellent examples).

 I am struggling with understanding:
 1. how to parse the array returned in $connection


foreach ($content as $id) {
  // this will iterate over all ids and each $id will be an int.
  var_dump($id)'
}


 2. how to implement a curser to get the next batch of responses
 (twitter seems to give me the first thousand only)


By default friends/ids returns all friends. If you wish to use cursors to
chunk ids into blocks of 5000 you will initially call:

$content = $connection-get('friends/ids', array('screen_name'
= 'bobaiello', 'cursor' = -1));

Then to get the next block:

$next_content = $connection-get('friends/ids', array('screen_name'
= 'bobaiello', 'cursor' = $content['next_cursor']));

If you are on 32bit machine you will probably have to use next_cursor_str
instead.



 3. is the array one dimensional or a more complex structure (print_r
 leads me to believe the latter)


It is a simple array(1, 2, 3, 4) unless using cursors array('ids' =
array(1, 2, 3, 4,), 'next_cursor' = 123456,...)

 any help or pointing me in the right direction would be greatly
 appreciated.


 Bob
 http://www.linkedin.com/in/BobAiello
 twitter: bobaiello, cmbestpractices, yellowspiderinc

  /**
   * GET wrapper for oAuthRequest.
   */
  function get($url, $parameters = array()) {
$response = $this-oAuthRequest($url, 'GET', $parameters);
echo mytest =.$response;
if ($this-format === 'json'  $this-decode_json) {
  return json_decode($response);
}
return $response;
  }

 --
 Twitter developer documentation and resources: http://dev.twitter.com/doc
 API updates via Twitter: http://twitter.com/twitterapi
 Issues/Enhancements Tracker:
 http://code.google.com/p/twitter-api/issues/list
 Change your membership to this group:
 http://groups.google.com/group/twitter-development-talk?hl=en


-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en