Does this module allow for extracting location information from a feed that could be placed into the location fields? If yes, how would I go about accomplishing this? Thanks!

Comments

crystaldawn’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not quite sure what you are asking but if you mean can you parse out the Domain name from the link field? Yes you can do that very easily. Take the following example feed:

$feed_data = "<title>Nokia 3650 Combines Phone And Photos</title>
<description>I've been playing with the new Nokia 3650. Finally, someone has got the combination of a cell phone with digital camera capabilities right!</description>
<link>http://allgadgetsreviewed.com/nokia3650.html</link>";

$location = between('http://', '/', $feed_data);

This would make $location == 'allgadgetsreviewed.com'

crystaldawn’s picture

Oh, I just looked up some of your recent posts and I see you asked about the Geographic Location in another thread. So yes actually you've landed in the right place actually. I can show you how to do that using this here module ;) I'll whip up an example and post it in a few mins. It could probably be made into it's own little module if to maybe.

crystaldawn’s picture

Here you go. Note that allow_url_fopen = On should be present in your php.ini file for the file_get_contents() function to work. Otherwise you'll either need to enable it or change it to use curl instead. But either method will work fine with this API.


$feed_link =  'http://www.nhc.noaa.gov/gtwo.xml';
$domain_name = between('http://', '/', $feed_link);

$feed_whois_data = file_get_contents("http://www.hostip.info/index.html?spip={$domain_name}");
$location = between('Location: <b>', '</b>', $feed_whois_data, FALSE);
//$location == 'Anaheim, CA, UNITED STATES'

crystaldawn’s picture

Status: Postponed (maintainer needs more info) » Needs review
k.a.b.’s picture

Thanks, it is good to know that the possibility is there. I have used Feed API to parse info (with simpleaspie) into nodes, so obviously it was very simple. I am new to parsing info, is there any tutorials that would help me to understand what to do with the code you generously provided?

crystaldawn’s picture

Not really, this code is geared towards a PHP Developer. So any PHP Developer would know what to do with it. It's not really for every day drupal users. If you dont know PHP, there really isnt much you can do other than ask someone to use this API so that your feeds could have geographical locations associated with them. If you were to show the 4 lines of code to someone who knew PHP then they would tell you that it would be very easy to do, because it really is, unless you dont do php ;) But the main idea would be to modify the data that comes from Feed API so that you can inject the physical location into it's object. Then you can output the data in a template. API's are generally for use by PHP Developers only. Users only DL and use them because the apps they want to use have a dependency on the API. So I guess the bottom line for you is that you now know how to do it, you just need to find someone who can put it to use.

crystaldawn’s picture

Status: Needs review » Closed (fixed)
summit’s picture

Subscribing, interested in getting location-info out of feed (feedapi) also.

EDIT: Just filed a feature-request on the feedapi issue queue.

greetings,
Martijn

AntiNSA’s picture

subscribe