Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running sample event code #2

Open
brianhanifin opened this issue Jun 11, 2014 · 3 comments
Open

Error running sample event code #2

brianhanifin opened this issue Jun 11, 2014 · 3 comments

Comments

@brianhanifin
Copy link

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

@thephphero
Copy link

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
Copy link

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)

@mmrk09
Copy link

mmrk09 commented Nov 13, 2014

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants