B4A Library Facebook

analizer3816

Member
Licensed User
Longtime User
***I use this code and it's work***
Sub LoginButton_Click

fb.LoginWithPermissions(Array As String(fb.PERMISSION_PUBLISH_ACTIONS))

End Sub
 

ivanomonti

Expert
Licensed User
Longtime User
yes perfect,

what are the permits, there is a full list of permissions that can be added, such as calendars, message etc. etc.
 

ivanomonti

Expert
Licensed User
Longtime User
***I use this code and it's work***
Sub LoginButton_Click

fb.LoginWithPermissions(Array As String(fb.PERMISSION_PUBLISH_ACTIONS))

End Sub

continuously have errors in my project, give me help you understand where I'm wrong!

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'facebook module
    Dim fb As Facebook
    Dim AppID As String = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
    Dim AppSecret As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    Dim myWebsite As String = "http://www.ivanomonti.eu"
End Sub

Sub Activity_Create(FirstTime As Boolean)
    fb.Initialize(Activity, Me, "myFB", AppID, AppSecret, myWebsite)
    LoginFacebook
    Dim bt As Button
    bt.Initialize("bt")
    bt.Text = "post"
    Activity.AddView(bt,10dip,10dip,100%x-20dip,42dip)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub bt_click
    PostToTimelineFacebook("Test message",myWebsite)
End Sub


#region facebook

Sub LoginFacebook
    fb.LoginWithPermissions(Array As String(fb.PERMISSION_PUBLISH_ACTIONS,fb.PERMISSION_PUBLISH_STREAM))
End Sub

Sub PostToTimelineFacebook(message As String, link As String)
    fb.PostToTimeline("me", message, link)
End Sub

Sub myFB_Facebook_ErrorMessages(Message As String)
    'Msgbox2(Message, "Facebook Error", "Close", "", "",Null)          
End Sub

Sub myFB_MyProfile_Response(Profile As Map)

    Dim Temp As String

    For I = 0 To Profile.Size - 1
        Temp = Temp & Profile.GetKeyAt(I) & ": " & Profile.GetValueAt(I) & CRLF
    Next

    ToastMessageShow(Temp,True)              
  
End Sub

#End Region

Error: Bad Request
 

ivanomonti

Expert
Licensed User
Longtime User
[QUOTE = "analizer3816, posta: 381050, membro: 25325"] è necessario compilare il tuo sito web in linguetta avanzata (vedere in a01.jpg) -> OAuth valido redirect URI [/ QUOTE]

non si dispone di un esempio, io mi sto perdendo
 

ivanomonti

Expert
Licensed User
Longtime User
link redirectory = http://www.ivanomonti.eu/apifacebook/facebook.html

code page html


B4X:
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>cart</title>
</head>
<body>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'xxxxxxxxxxxxxxxxxxxxx',
      xfbml      : true,
      version    : 'v2.5'
    });
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>

that way I do not have error json, but I can not post the arrivandomi bad request

B4X:
    Dim fb As Facebook
    Dim AppID As String = "xxxxxxxxxx"
    Dim AppSecret As String = "xxxxxxxxxxxxxxxxxxxxxxx"
    Dim myWebsite As String = "http://www.ivanomonti.eu/apifacebook/facebook.html"

HELP :-(
 

ivanomonti

Expert
Licensed User
Longtime User
I create html file with your code on my server, it never error json
when I use http://www.ivanomonti.eu/apifacebook/facebook.html, it error json



I regenerated new app of facebook, leaving all settings as default, put the link redirectory, but the problem persite.

I point if the file does not have a problem with the message json, but then I can not prune, if you do not point the full link redirectory me by mistake but I can post json.

I do not know how to move in this situation
 

ivanomonti

Expert
Licensed User
Longtime User
[QUOTE = "analizer3816, posta: 381.501, membro: 25325"] è possibile verificare con il mio link http://www.phothitham.ac.th/facebook.html e vedere il mio codice per confrontare con il tuo

il mio server uso iis8.5 su win2012r2 [/ QUOTE]

HTML:
<html>
    <head>
        <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
        <title>facebook</title>
    </head>
    <body>
        <script>
          window.fbAsyncInit = function() {
            FB.init({
              appId      : '1667411463500049',
              xfbml      : true,
              version    : 'v2.5'
            });
          };
          (function(d, s, id){
             var js, fjs = d.getElementsByTagName(s)[0];
             if (d.getElementById(id)) {return;}
             js = d.createElement(s); js.id = id;
             js.src = "//connect.facebook.net/en_US/sdk.js";
             fjs.parentNode.insertBefore(js, fjs);
           }(document, 'script', 'facebook-jssdk'));
        </script>
        <div class = "fb-like"-share dati = "true"-width dati = "450" dati-show-facce = "true"> </ div>
    </body>
</html>

thank
 

ivanomonti

Expert
Licensed User
Longtime User
I have not managed to solve the problem json to login, I can post it on facebook, but the error message of json and ugly to look at, I want to solve it, who gives me a hand with.
 

Leni Berry

Active Member
Licensed User
Longtime User
Hi,

how to get email address after login successfully?
i 'hv added permission fb.USER_FIELD_EMAIL and added also to fb.getfields array. but, the email not shown in JSONText under Sub myFB_GetFields_Response(JSONText As String).
i can get all field like name, picture, id and gender. but not for the email
Please help me...
 

Leni Berry

Active Member
Licensed User
Longtime User
what a mistake...
permission added is wrong permission...
i hv added permission fb.permission_email and the email show in JSONText object...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…