0

I have this sourcecode :

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.net.URL;

import facebook4j.Account;
import facebook4j.Facebook;
import facebook4j.FacebookFactory;
import facebook4j.PostUpdate;
import facebook4j.auth.AccessToken;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);




        try{
        Facebook facebook = new FacebookFactory().getInstance();
        facebook.setOAuthAppId(String.valueOf(R.string.facebook_app_id), String.valueOf(R.string.facebook_app_secret));

         facebook.setOAuthAccessToken(new facebook4j.auth.AccessToken("10000000000003|mqs000000000000C46A"));

        String pageToken = "EAAUB000000000000000000000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AZDZD";

        for (Account a : facebook.getAccounts()) {
            if (a.getName().toLowerCase().contains("nameOfPage")) {

                pageToken = a.getAccessToken();


                PostUpdate post = new PostUpdate(new URL("https://facebook.com/1000000000000003/feed"))
                        .picture(new URL("http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png"))
                        .name("example name")
                        .caption("example caption")
                        .message("example message")
                        .description("example description");

                if (pageToken != null) {
                    facebook.setOAuthAccessToken(new AccessToken("EAAUB000000000000000000000000000000000000000000000000000123000000000000000000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000000AZDZD"));
                    facebook.postFeed(post);
                    //ScriptGroup.Input.addInfoAnnotation(req, "sysAdminTools.annotation.fb.ok");
                }

            }


        }
    }catch(Exception e){
System.out.println();
        }
    }
}

With manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="test.app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
        <provider android:authorities="com.facebook.app.FacebookContentProvider1400000000000003"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true" />
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

and it is not working. I am trying to Google it for over a hour and I cant find anything expect this. I have PageToken, AppToken with AppSecret already generated by myself. Can you please explain me whats wrong and recommend sollution?

Every time I press button logcat shows this but nothing happen:

09-11 8:24:69.420 28087-28087/test.app I/HwSecImmHelper: mSecurityInputMethodService is null

App is not crashing, no errors are thrown, just nothing is happening at all.

Thanks

Community
  • 1
  • 1
antoninkriz
  • 966
  • 4
  • 18
  • 36
  • What version of Facebook SDK is Facebook4J using? It might be an old version, Facebook SDK 4.0+ was a great upgrade. Just like Fabric Twitter API, Twitter4J is unnecessary these days. – Lev Sep 29 '16 at 14:32
  • @Lev i dont know exactly now from the head but I downloaded it like a month ago (sent from phone) – antoninkriz Sep 29 '16 at 16:21

0 Answers0