我正在努力从Facebook检索电子邮件。它应该很简单,但我不知道它为什么不返回。以下是代码。
protected function getRelationshipFromMethod($method)
{
// Different relationships return different types of data so
// tweak this as necessary. In theory you only care if the relationship
// type is a single entity rather than a collection.
$results = parent::getRelationshipFromMethod($method);
if ($results instanceOf Illuminate\Database\Eloquent\Collection) {
return $results;
}
// Generate a null value for any missing attributes
// PHP7 anonymous class. Return a real class < 7.0
return $this->relations[$method] = new class {
public function __get($attribute) {
return null;
}
};
// Or perhaps actually create a relationship with a specification
$this->relations[$method] = Specification::where('default', true)->first();
$this->specification()->associate($this->relations[$method]);
return $this->relations[$method];
}
这是检索除电子邮件之外的所有其他字段。
答案 0 :(得分:3)
根据facebook documentation
如果没有有效的电子邮件地址,则不会返回此字段。
可以在不给出电子邮件地址的情况下注册Facebook。可以使用手机号码。其中一位facebook工程师也提供了完整的解释: https://developers.facebook.com/bugs/298946933534016