Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing Twitter feeds in C
    primarykey
    data
    text
    <p>I'm trying to figure out how to get the most recent latitude and longitude of a Twitter user (from the new Geo API data, ie the <code>&lt;geo:point&gt;</code> tag, you can see how they look like on <a href="http://twitter.com/statuses/user_timeline.xml?screen_name=jphastings" rel="nofollow noreferrer">my twitter user timeline xml feed</a>). I also need to retrieve how old that data is (in seconds) from the <code>&lt;created_at&gt;</code> tag.</p> <p>I'm trying to write this in C to use with an <a href="http://mbed.org" rel="nofollow noreferrer">mbed microcontroller</a> so I can't use any big libraries (ideally I wouldn't use any libraries, but that might be a bad idea). The mbed site suggests <a href="http://mbed.org/users/rolf/notebook/random-libraries/" rel="nofollow noreferrer">a few light libraries</a> - <a href="http://lloyd.github.com/yajl/" rel="nofollow noreferrer">YAJL</a> and FastXML seem useful - but my C knowledge is very basic and I'm unsure as to how to proceed.</p> <p>Assuming I have the code for retrieving a twitter user timeline into memory as a string and/or to disk (as either JSON or XML) how should I proceed?</p> <p>At the moment I'm doing this scraping on my webserver via PHP, but I'd rather have it done in C as I hope to release the code when I'm done (and I don't want my poor server being rammed!) The PHP looks like this:</p> <pre><code>&lt;?php date_default_timezone_set('UTC'); try { $tweets = json_decode(file_get_contents("http://twitter.com/statuses/user_timeline.json?screen_name=".urlencode($_GET['screenname']))); foreach($tweets as $tweet) { if (is_array($tweet-&gt;geo-&gt;coordinates)) { echo date("U") - strtotime($tweet-&gt;created_at); echo ",{$tweet-&gt;geo-&gt;coordinates[0]},{$tweet-&gt;geo-&gt;coordinates[1]}"; break; } } } catch (Exception $e) { exit(); } </code></pre> <p>This works fairly well, but I have no idea how to turn this into C! Any ideas?</p> <p>Here's a snippet of the XML I'm expecting to deal with:</p> <pre><code>&lt;statuses type="array"&gt; &lt;status&gt; &lt;created_at&gt;Sat Dec 12 22:25:17 +0000 2009&lt;/created_at&gt; &lt;id&gt;6611101548&lt;/id&gt; &lt;text&gt;Hello stackoverflow! This tweet is geotagged.&lt;/text&gt; &lt;other tags/&gt; &lt;geo&gt; &lt;georss:point&gt;52.946972 -1.182846&lt;/georss:point&gt; &lt;/geo&gt; &lt;/status&gt; &lt;status ...&gt; &lt;/statuses&gt; </code></pre> <p>(btw, the mbed is awesome, I'm having an amazing time with it despite my lack of advanced knowledge in C or electronics, they're <a href="http://uk.farnell.com/nxp/om11043/kit-mbed-prototyping-board-lpc1768/dp/1761179" rel="nofollow noreferrer">in stock at Farnell</a> for £32 and definitely worth the money!)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload