从Facebook获取用户ID

问题描述 投票:0回答:1

我想知道如果我只获得用户的个人资料(个人资料用户名/链接),仍然可以获得Facebook用户ID吗?

例如:

https://www.facebook.com/zuck 

我试图用SDK和Graph API做到这一点,但似乎所有以前的解决方案都不起作用。你能给我一个提示吗?我想进一步,但我不确定哪种方式是正确的。

facebook facebook-graph-api userid
1个回答
0
投票

你可以用Excel做到这一点。我把我使用的宏。您必须将名称放在第一列中,并在运行GenerateFaceIds宏时在第二列中生成id。 (您需要在IExplorer中登录Facebook)

Sub GenerateFaceIds()
  Dim total As Long
  total = 1

   Do Until IsEmpty(Cells(total, 1)) = True
   If (Cells(total, 2) = "") Then
       Call faceId(total)
    End If
    total = total + 1
   Loop

    MsgBox ("OK")
End Sub

Sub faceId(row As Long)
    On Error GoTo ErrHandler

    Dim appIE As Object
    Set appIE = CreateObject("internetexplorer.application")

    Dim id As String
    id = Cells(row, 1)

    With appIE
        .Navigate "https://www.facebook.com/" + id
        .Visible = False
    End With

    Do While appIE.Busy
    DoEvents
    Loop

    Text = appIE.Document.Body.innerHTML

    posinter = InStr(Text, "profile_owner")
    profile_owner = Mid(Text, posinter + 16, 15)

    posinter2 = InStr(profile_owner, """")
    If posinter2 > 0 Then
        profile_owner = Left(profile_owner, posinter2 - 1)
    End If

    Cells(row, 2) = profile_owner

    appIE.Quit
    Set appIE = Nothing

ExitSub:

    Exit Sub

ErrHandler:
    'MsgBox "Something's wrong"

    appIE.Quit
    Set appIE = Nothing

    Resume ExitSub
    Resume

End Sub

结果:

调整4

© www.soinside.com 2019 - 2024. All rights reserved.