logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ how to add facebook login to php website

HOW TO ADD FACEBOOK LOGIN TO PHP WEBSITE

by Admin _ November 28, 2022
I have a Facebook desktop application và am using the Graph API.I am able to get the access token, but after that is done - I don"t know how to get the user"s ID.

Bạn đang xem: How to add facebook login to php website

My flow is lượt thích this:

In my redirect page I get the code from Facebook.

Then I perform a HTTP request to lớn graph.facebook.com/oauth/access_token with my API key and I get the access token in the response.

From that point on I can"t get the user ID.

Xem thêm: Share Code Bán Máy Tính Php Mysql ( Source Code Đồ Án 2020 )

How can this problem be solved?


*

*

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
If you want lớn use Graph API lớn get current user ID then just send a request to:

https://graph.facebook.com/me?access_token=...

*

The easiest way is

https://graph.facebook.com/me?fields=id&access_token="xxxxx"then you will get json response which contains only userid.


*

The facebook acess token looks similar too"1249203702|2.h1MTNeLqcLqw__.86400.129394400-605430316|-WE1iH_CV-afTgyhDPc"

if you extract the middle part by using | khổng lồ split you get

2.h1MTNeLqcLqw__.86400.129394400-605430316

then split again by -

the last part 605430316 is the user id.

Here is the C# code to extract the user id from the access token:

public long ParseUserIdFromAccessToken(string accessToken) * user id */ long userId = 0; var accessTokenParts = accessToken.Split("WARNING: The structure of the access token is undocumented và may not always fit the pattern above. Use it at your own risk.

UpdateDue to lớn changes in Facebook.the preferred method khổng lồ get userid from the encrypted access token is as follows:

try var fb = new FacebookClient(accessToken); var result = (IDictionary)fb.Get("/me?fields=id"); return (string)result<"id">;catch (FacebookOAuthException) return null;

Share Tweet Linkedin Pinterest
Previous Post

Php check inarray

Next Post

Giải mã code file php bị decode zend guard

CÙNG CHUYÊN MỤC

form register php

Form register php

09/04/2021
fantastic blog (cms) in php with source code

Fantastic blog (cms) in php with source code

28/04/2021
validate form php javascript

Validate form php javascript

28/04/2021
http diendanlequydon com viewtopic php style 6

Http diendanlequydon com viewtopic php style 6

28/04/2021
cách cài đặt php 7

Cách cài đặt php 7

24/01/2023
rövid videó

Rövid videó

23/01/2023
installing apache php mysql on ubuntu 18

Installing apache php mysql on ubuntu 18

20/01/2023
tính kế thừa trong oop php

Tính kế thừa trong oop php

20/01/2023

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Web server

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.