LifePress icon indicating copy to clipboard operation
LifePress copied to clipboard

Foursquare plugin, Latitude/Longitude error (simplepie changes)

Open therourke opened this issue 12 years ago • 0 comments

Hello

I wrote a plugin for Foursquare (on Sweetcron) that pulls latitude and logitude information from the feed and outputs a relevant Google map as the image background.

I was getting errors, and figured out why, but thought it was worth sharing the error, as it might come in useful. (something to do with a simplepie change?)

Here is the error read out (shown at the top of admin):

Severity: Notice
Message: Undefined index: geo
Filename: plugins/foursquare_com.php
Line Number: 24
Backtrace:
File: /home/content/t/h/e/therourke/html/machine/stream/application/plugins/foursquare_com.php
Line: 24
Function: _exception_handler
File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 143
Function: pre_display
File: /home/content/t/h/e/therourke/html/machine/stream/application/models/item_model.php
Line: 96
Function: extend
File: /home/content/t/h/e/therourke/html/machine/stream/application/models/item_model.php
Line: 168
Function: _process
File: /home/content/t/h/e/therourke/html/machine/stream/application/controllers/admin/dashboard.php
Line: 55
Function: get_all_items
File: /home/content/t/h/e/therourke/html/machine/stream/index.php
Line: 251
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined index: geo
Filename: plugins/foursquare_com.php
Line Number: 24
Backtrace:
File: /home/content/t/h/e/therourke/html/machine/stream/application/plugins/foursquare_com.php
Line: 24
Function: _exception_handler
File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 143
Function: pre_display
File: /home/content/t/h/e/therourke/html/machine/stream/application/models/item_model.php
Line: 96
Function: extend
File: /home/content/t/h/e/therourke/html/machine/stream/application/models/item_model.php
Line: 168
Function: _process
File: /home/content/t/h/e/therourke/html/machine/stream/application/controllers/admin/dashboard.php
Line: 55
Function: get_all_items
File: /home/content/t/h/e/therourke/html/machine/stream/index.php
Line: 251
Function: require_once

and here's my original plugin, in full (note the 'geo' data that lifepress doesn't like):


<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

define('MAP_SIZE', '320x320');
define('MAP_ZOOM', '13');
define('NS_GEORSS', 'http://www.georss.org/georss');

class Foursquare_com {

    //Foursquare Class 0.1a

    function pre_db($item, $original)
    {
        $_coords = $original->get_item_tags( NS_GEORSS, 'point');
        list( $lat, $long ) = split( " ", $_coords[0]['data'] );
        $name = $_name[0]['data'];
        $type = $_type[0]['data'];      
        $item->item_data['geo']['lat'] = $lat;
        $item->item_data['geo']['long'] = $long;            
            return $item;
            }

    function pre_display($item)
    {
        $latlong = $item->item_data['geo']['lat'] . ',' . $item->item_data['geo']['long'];
        $item->item_data['image'] = 'http://maps.google.com/maps/api/staticmap?center='.$latlong.'&markers='.$latlong.'&zoom='.MAP_ZOOM.'&size='.MAP_SIZE.'&sensor=false';
        return $item;
    }
}

After I removed the ['geo'] sections (leaving just ['lat'] or ['long']), everything worked fine again, but now I get a different error in the admin panel:


A PHP Error was encountered

Severity: Notice

Message: Undefined variable: _name

Filename: plugins/foursquare_com.php

Line Number: 15

Backtrace:

File: /home/content/t/h/e/therourke/html/machine/stream/application/plugins/foursquare_com.php
Line: 15
Function: _exception_handler

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 143
Function: pre_db

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 109
Function: extend

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 85
Function: add_new_items

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 66
Function: fetch_item

File: /home/content/t/h/e/therourke/html/machine/stream/application/controllers/admin/items.php
Line: 84
Function: fetch_items

File: /home/content/t/h/e/therourke/html/machine/stream/index.php
Line: 251
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: _type

Filename: plugins/foursquare_com.php

Line Number: 16

Backtrace:

File: /home/content/t/h/e/therourke/html/machine/stream/application/plugins/foursquare_com.php
Line: 16
Function: _exception_handler

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 143
Function: pre_db

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 109
Function: extend

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 85
Function: add_new_items

File: /home/content/t/h/e/therourke/html/machine/stream/application/libraries/lifepress.php
Line: 66
Function: fetch_item

File: /home/content/t/h/e/therourke/html/machine/stream/application/controllers/admin/items.php
Line: 84
Function: fetch_items

File: /home/content/t/h/e/therourke/html/machine/stream/index.php
Line: 251
Function: require_once

Seems to not like these lines:

$name = $_name[0]['data'];
$type = $_type[0]['data'];  

Removing them solves the problem. Why were they there in the first place? I can't remember...

therourke avatar Jun 19 '12 19:06 therourke