1

I am developing a console app with c# to autopost photos to my facebook page. The code below does the job successfully (post photo to facebook page) but all my photos gets '0 person viewed' although they are public:

var fb = new FacebookClient(access_token);
var argList = new Dictionary<string, object>();
            var media = new FacebookMediaObject
            {
                FileName = System.IO.Path.GetFileName(path),
                ContentType = "image/jpg"
            };
            media.SetValue(System.IO.File.ReadAllBytes(path));
        argList["source"] = media;
 fb.Post("/{page_id}/photos", argList);

So I think the problem is with the last line of code, I should write

fb.Post("/{page_id}/feed", argList);

instead of this:

fb.Post("/{page_id}/photos", argList);

But whenever I try this, I get this exception:

(OAuthException - #100) (#100) source should represent a valid URL

I have seen some examples on the net where the method Post have just one parameter like that:

fb.Post(argList);

But when I have tried it, I got this exception

(GraphMethodException - #100) Unsupported post request. Please read the Graph API documentation

Note: when I post a picture normally from the page without a 3rd party, the post gets around 300 views.

So what's wrong with my code ? How can I post a picture from my app and got shown like it is posted from an account ?

andyrandy
  • 72,880
  • 8
  • 113
  • 130
Wassim01
  • 189
  • 3
  • 11
  • is your app live? make sure the settings are correct. – andyrandy Jan 08 '19 at 19:43
  • Settings of the app are correct – Wassim01 Jan 08 '19 at 19:59
  • why did you re-add the visual-studio and js sdk tags? you are not using the js sdk anywhere in your question, and the visual-studio tag description clearly says that you should only use it for questions specifically about visual studio. only use relevant tags, don´t just add unrelated ones. – andyrandy Jan 08 '19 at 20:10
  • anyway, the photos endpoint is there to post photos, the feed endpoint is for messages and links (that may have an open graph image attached). if your app settings are really correct (i would add a screenshot if i were you), then it should show up on the page. – andyrandy Jan 08 '19 at 20:13
  • It is a `console app` for personal use. Settings are set to default. The picture is showing app on the page but it has 0 person viewed so I should use feed endpoint for the picture appears properly for my audience. @luschn – Wassim01 Jan 08 '19 at 20:39
  • "Settings are set to default" - default is NOT live, that´s why i asked... – andyrandy Jan 08 '19 at 21:09
  • Okay so is there any solution to the problem I am facing ? @luschn – Wassim01 Jan 08 '19 at 21:24
  • as i said, make sure the app is live. there is a specific setting for that in the app review section. – andyrandy Jan 08 '19 at 21:31
  • What app ? The console app I am developing or the app I created in Facebook developers and how can I make it live ? @luschn – Wassim01 Jan 09 '19 at 17:17
  • the facebook app you created here: https://developers.facebook.com/apps – andyrandy Jan 09 '19 at 17:19

1 Answers1

0

Posts of Apps that are not live are only visible to users with a role in the App. There is a checkbox in the upper right corner of your Facebook App settings (https://developers.facebook.com/apps) that lets you put it live.

Update: It may be needed to go through the review process with the required permissions.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • My app is live now, I am getting this exception when running my app: `The permission(s) manage_pages,publish_pages are not available`. Although I have those permissions in my access token – Wassim01 Jan 09 '19 at 19:59
  • where exactly do you get that error? "when running my app" is quite vague. – andyrandy Jan 09 '19 at 20:22
  • at `fb.Post("/{page_id}/photos", argList);` – Wassim01 Jan 10 '19 at 13:01
  • Yes before my app went live, Now after it is live I am getting this exception at this line of code – Wassim01 Jan 10 '19 at 15:58
  • ok, this is just an assumption, but: if it is not live, regular users cannot see posts made by the app. and if you are live, you have to go through the review process with the required permissions in order to use them. so, basically, you have to get everything approved by facebook before going live. – andyrandy Jan 10 '19 at 16:16
  • Is there a way to resolve the problem (to ask for permission during app run with code or something) without going through app reviewing with facebook because they are very demanding hard to get approved ? In this thread: https://stackoverflow.com/questions/43034438/posting-to-facebook-only-available-to-admin-c-sharp he just took his app live and didn't seem that he passed through this app reviewing ? – Wassim01 Jan 10 '19 at 19:59
  • to be honest, i have never heard that an app suddenly does not work anymore just because you set it live. is that really the only difference? of course, it may be possible that facebook requires approval even for your case nowadays. – andyrandy Jan 11 '19 at 07:25
  • Yes it is the only difference I have changed nothing in code. I even have tried creating a new app and get new access token and made it live, the same exception reappeared. – Wassim01 Jan 11 '19 at 09:25
  • ok, then i guess it´s the update in my answer, i´m afraid you will have to do the review – andyrandy Jan 11 '19 at 09:33
  • Is there a way to keep my app in development mode and still reach audience with my posts ? – Wassim01 Jan 11 '19 at 09:34
  • i don´t think so, no. – andyrandy Jan 11 '19 at 09:35