Implementation of Pods API in an external PHP file

0

hey guys i wanted to use PODS functions in an external PHP file, so i included the blog-header.php & the functions are accessible, so i tried doin an insert to test out the API save_pod_item method but i got an error could you please help me with this

<?php

include 'wp-blog-header.php';

$api = new PodAPI();

$params = array('datatype' => 'deal', 'columns' => array('test_views_day' => '500', 'test_views_dates' => '6-7-2010'));

// create the item
$person_id = $api->save_pod_item($params);
?>

//test_views_day is a num field
//test_views_dates is a date field

Error: Parse error: syntax error, unexpected '[' in /home/kunal17/public_html/devbuzzr/wp-content/plugins/pods/classes/PodAPI.php(501) : eval()'d code on line 2

asked Sep 13 '10 at 11:42

acenik

1

add comment
enter at least 15 characters

3 Answers

0

Looks like there's some trouble with one of your Pre-save / Post-save Helpers. Check there or post the code for review.

answered Sep 13 '10 at 3:01

sc0ttkclark

2936

add comment
enter at least 15 characters
0

thanks, it was a pre-save helper had a $ missing

$columns['slug']['value'] = sanitize_title(columns['post_name']['value']);

should have been

$columns['slug']['value'] = sanitize_title($columns['post_name']['value']);

but what i fail to understand is that this code was working when a entry was added by the UI of pods, but when i used the API it showed this error, & how is it that without the $ sign the value even showed up?

answered Sep 14 '10 at 8:55

acenik

1

add comment
enter at least 15 characters
0

I'm not sure why it would work when adding via the normal UI of Pods, other than the normal form uses AJAX for submission and could be masking the real problem. If the slug is empty, it will automatically use the 'name' field of the Pod item.

answered Sep 14 '10 at 1:52

sc0ttkclark

2936

add comment
enter at least 15 characters