ทำระบบ Facebook Login PHP SDK ดึงอีเมล์ไม่ได้

เริ่มโดย thaidreamhost, 17 กันยายน 2014, 07:10:20

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

thaidreamhost

คือค่าต่างๆได้หมดแล้ว แต่ไม่ได้ค่า อีเมล์นะครับ
อ้างถึง
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => 'xxxxx',
  'secret' => 'xxxxxx',
  'cookie' => true
));

// Get User ID
$user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
   echo 'Caught exception: ',  $e->getMessage(), "\n";
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');


   $fb_id =$user_profile['id'];
   $dealmember_fbid = $user_profile['id'];
   $fb_name =$user_profile['name'];
   $fb_first_name =$user_profile['first_name'];
   $fb_last_name =$user_profile['last_name'];
   $fb_link =$user_profile['link'];
   $fb_username =$user_profile['username'];
   $fb_gender =$user_profile['gender'];
   $contact_email = $user_profile["contact_email"];     //this was a separate permission, remember?
   $email = $user_profile["email"];     //this was a separate permission, remember?
   
   echo " fb_id = $fb_id <br>";
   echo " dealmember_fbid = $dealmember_fbid <br>";
   echo " fb_name = $fb_name <br>";
   echo " fb_first_name = $fb_first_name <br>";
   echo " fb_last_name = $fb_last_name <br>";
   echo " fb_link = $fb_link <br>";
   echo " fb_username = $fb_username <br>";
   echo " contact_email = $contact_email <br>";
   echo " email = $email <br>";
ตรง contact_email  กับ email มันไม่แสดงค่าอะไรเลย

ไม่แน่ใจว่า para มันคืออะไร หรือต้อง set ค่าอะไรก่อนหน้านี้หรือเปล่าครับ

ขอบคุณครับ
[direct=http://www.vouchercar.com]บัตรรถเช่า[/direct]
[direct=http://www.ejobonline.com]เว็บหางาน สมัครงาน ประกาศงาน ออนไลน์[/direct]
[direct=http://www.thaitoursearch.com]จองโรงแรม ทัวร์ ตั๋วเครื่องบิน[/direct]
[direct=http://www.rackserverthai.com]ตู้ rack[/direct]

nineton

รับซื้อเว็บไซท์ 10,000 UIP ขึ้นไปประเภท บันเทิง,หนัง,เพลง,เว็บบอร์ด เสนอราคาได้ทาง PM ครับ

JumDaiDee

ของผมใช้แบบนี อะไรๆ ก็ดึงมาได้หมดนะครับ ลองดู

อ้างถึง$fbuser = $facebook->getUser();
   if ($fbuser) {
      try {
          $user_profile = $facebook->api('/me');
      }
      catch (Exception $e) {
         echo $e->getMessage();
         exit();
      }

      $user_email = $user_profile["email"];
      $user_fnmae = $user_profile["first_name"];
      $user_image = "https://graph.facebook.com/".$user_fbid."/picture?type=large";
   }
สินค้าออนไลน์ https://www.shoppook.com/product | โปรแกรมออนไลน์ : https://appnon.com

dekdoo

ผมเคยทำระบบสมัครผ่านการล็อกอิน facebook แล้วดึงค่ามาเก็บ
- Facebook บาง account ดึงเมล์ ชื่อ id ได้หมด
- Facebook บาง account ดึง ชื่อ id ทุกอย่างมาได้หมด ยกเว้นเมล์ ที่ดึงไม่ได้ สอบถามไป สอบถามมา ปรากฏว่า อีเมล์ตัวนั้นที่ใช้ล็อกอิน facebook ตัวนั้น user บอกว่า
มันใช้งานอีเมล์ไม่ได้แล้ว แต่ยังใช้ล็อกอิน facebook ได้อยู่ครับ

สรุปใจความที่ได้คือ หากอีเมล์ที่ลงใช้งาน facebook โดนยกเลิกหรือถูกระงับไปแล้ว (เฉพาะอีเมล์นะ ไม่ใช่ facebook) โอกาศที่จำทำแอพ facebook แล้วดึง email ออกมานั้นจะไม่เจอครับ

esanza.com

อ้างถึงจาก: dekdoo ใน 17 กันยายน 2014, 09:32:16
ผมเคยทำระบบสมัครผ่านการล็อกอิน facebook แล้วดึงค่ามาเก็บ
- Facebook บาง account ดึงเมล์ ชื่อ id ได้หมด
- Facebook บาง account ดึง ชื่อ id ทุกอย่างมาได้หมด ยกเว้นเมล์ ที่ดึงไม่ได้ สอบถามไป สอบถามมา ปรากฏว่า อีเมล์ตัวนั้นที่ใช้ล็อกอิน facebook ตัวนั้น user บอกว่า
มันใช้งานอีเมล์ไม่ได้แล้ว แต่ยังใช้ล็อกอิน facebook ได้อยู่ครับ

สรุปใจความที่ได้คือ หากอีเมล์ที่ลงใช้งาน facebook โดนยกเลิกหรือถูกระงับไปแล้ว (เฉพาะอีเมล์นะ ไม่ใช่ facebook) โอกาศที่จำทำแอพ facebook แล้วดึง email ออกมานั้นจะไม่เจอครับ


ผมเคยทำครับ แต่นานละ Account เก่าๆ(6-8 ปีที่แล้ว)จะดึงอีเมล์ไม่ได้ครับ
วิธีแก้ปัญหาเบื้องต้นก็คือเขียนระบบเช็คถ้าไม่มี Email ก็โชว์ให้กรอกอีเมล์
แค่นี้ก็จบครับ  :wanwan016:
ใครต้องการเช่าโฮสที่มี Control Panel ดีๆ
และ Support ดี แนะนำ => [direct=https://support.hostatom.com/aff.php?aff=456]โฮสอะตอม[/direct]

thaidreamhost

ตอนนี้ ได้แล้วครับ

แก้โดย

อ้างถึงif ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {

    $loginUrl = $facebook->getLoginUrl( array('scope' => 'email,read_stream'));
}

[direct=http://www.vouchercar.com]บัตรรถเช่า[/direct]
[direct=http://www.ejobonline.com]เว็บหางาน สมัครงาน ประกาศงาน ออนไลน์[/direct]
[direct=http://www.thaitoursearch.com]จองโรงแรม ทัวร์ ตั๋วเครื่องบิน[/direct]
[direct=http://www.rackserverthai.com]ตู้ rack[/direct]