Meetup icon indicating copy to clipboard operation
Meetup copied to clipboard

Error running sample event code

Open brianhanifin opened this issue 11 years ago • 3 comments

Hello, I want to use your library to extra the list of events in my meetup group. I can get the JSON response in the API console, and your library returns it (I proved it by displaying the output of print_r($response)). However, I am getting an error when trying to use your example array iteration code.

I used to be a web developer, but I used ASP mostly, and am generally rusty when it comes to coding so it might be something simple I overlooked. Do you have any thoughts why the sample code doesn't work? My code is on github for you to see, and I included the print_r() output in a gist link below.

_Error_ Warning: Invalid argument supplied for foreach() in pbm-meetup-events/import.php on line 20

_print_r($response) output_ https://gist.github.com/brianhanifin/db8eece1b454b06341b6

brianhanifin avatar Jun 11 '14 18:06 brianhanifin

I am having this exact same issue. If I do a var_dump($response) I notice that an array is returned instead of an object. I guess that is where the problem is. Any help would be appreciated

thephphero avatar Aug 06 '14 22:08 thephphero

I kind of fixed this by using $response in the foreach loop. So instead of $events = $response->results; I just did a foreach ($response as $event)

thephphero avatar Aug 06 '14 22:08 thephphero

I forked it and added OATH, cleaned up curl, and also cleaned up README/code to reflect what's in the readme now. So it will return a json object as the response so not only can you iterate over events like in the example but you get all the other meta and etc. information too which is useful.

So the examples are correct now,

$response = $meetup->getEvents(); foreach($response->results as $event) {

}

echo $response->meta->total_count;

mmrk09 avatar Nov 13 '14 00:11 mmrk09