CodepadME / laravel-tricks

The source code for the Laravel Tricks website
http://laravel-tricks.com
MIT License
966 stars 298 forks source link

GitHub.php: Invalid argument supplied for foreach() #68

Open michaelharper opened 10 years ago

michaelharper commented 10 years ago

screenshot 2014-07-14 17 43 26

Experiencing Invalid argument supplied for foreach() when I attempt to register with GitHub. Here is the function:

/**
 * Get the primary, verified email address from the Github data.
 *
 * @param  mixed $emails
 * @return mixed
 */
protected function getPrimaryEmail($emails)
{
    foreach ($emails as $email) {
        if (! $email->primary) {
            continue;
        }

        if ($email->verified) {
            return $email->email;
        }

        throw new GithubEmailNotVerifiedException;
    }

    return null;
}
michaelharper commented 10 years ago

So after some digging it seems that $emails is returning null. Anyone have an idea? I'm relatively new to OAuth. Thanks.

michaelharper commented 10 years ago

No one else is experiencing this issue....?

w3z315 commented 10 years ago

Hello there! I have reproduced this issue. It seems like that the GitHub API is blocking requests from my Vagrant machine. Do you use one too?

I noticed that if I open the requested API URL, I am receiving a correct response.

Unfortunately, I can not imagine any fixes for this issue. Any suggestions?

michaelharper commented 10 years ago

No suggestions, it appears I might have to disable GitHub registration until I can figure out how to use their API. Mine is actually happening on production and not just from vagrant.

marktopper commented 9 years ago

@deeperDATA, I have the same issue, did you found a way around?

michaelharper commented 9 years ago

@marktopper Nothing yet, I'm thinking about refactoring the Github integration completely. Love the framework but this is an important feature for my user demographic.