Facebook wall post error: OAuthException :: (#1500) The url you supplied is invalid
Asked Answered
P

4

7

I have a web-based news app that runs on Heroku. When users post a comment to a news story on my app, my app forwards the comment to the user's facebook wall using fb_graph. Everything worked perfectly until a couple of weeks ago. For no reason that I can explain I am now seeing some baffling behavior.

Now, when a user submits a comment to a story the FB API responds with, OAuthException :: (#1500) The url you supplied is invalid. If, the same user then submits additional comments to the same story those comments are posted to the user's FB feed just fine.

I have used the FB Graph API explorer to confirm that I have valid access tokens, and that my app does accept posts to the token-owner's FB feed.

To make things even more baffling, when running my web app in development on localhost all of the posts go through just fine to my development FB app.

def post_to_facebook(story, post) 
  auth = Authentication.find_by_provider_and_user_id("facebook", current_user.id)
  if auth
    me = FbGraph::User.me(auth.token)
    if me.permissions.include?(:publish_stream)
      begin
        me.feed!(
          :message => "#{best_name(current_user)} made the following post to NewsWick: #{post.contents}", 
          :name => story.title,
          :link => "https://www.newswick.com/stories/"+story.id.to_s,
          :description => "Story posted to the NewsWick world-wide news service" ,
          :picture => best_photo(story)[:photo_url]
          )
      rescue => e
        @msg = "Facebook posting error: "+ e.to_s
        puts "Facebook feed posting error: #{e.message}"
      end 
    else
      @msg = "No longer authorized to post to Facebook."
    end
  end
  return @msg
end

One last thing to note, the only thing that I have changed w/r/t how my app interacts with FB in the last two weeks was that i accepted FB's July Breaking Changes.

Anyone have any clues. This is driving me bonkers!!!

Putscher answered 15/5, 2013 at 19:20 Comment(0)
R
4

I'm having the same issue only difference is I'm using the javascript api.

Seems like it's a facebook bug, which is already reported here: https://developers.facebook.com/bugs/136768399829531

Ripe answered 16/5, 2013 at 16:49 Comment(4)
Yep. I've found five bug reports on the FB support forum. Hope that FB does something about this soon. developers.facebook.com/bugs/476666205677592, developers.facebook.com/bugs/126382447562342, developers.facebook.com/bugs/431421556904563, developers.facebook.com/bugs/460912230659216, and developers.facebook.com/bugs/136768399829531Putscher
@chuckw Did u try what I mentioned below?- See my response bwlow: Let me know if you need more help, thanksMiserable
@babajidePrince, just saw this suggestion. I'll try it in the morning and report back.Putscher
@BabajidePrince, Your suggestion did work to allow posting over the Rest API. It did trigger more, very bizarre behavior. Although the posts through to FB, the :picture param didn't always work to point to the appropriate photo. Once I put the :link param back in the :picture param worked 100% of the time, but about every 3rd post would fail with code #1500Putscher
M
3

Yes this is a known bug and Facebook developers are looking into it, well so they claim,however something interesting I found out is:

I post to my Facebook using 2 methods using RestFB API , first, for messages with URLs e.g www.something.com and those without URLs, I realized last night that all posts without URL worked and the ones with URL doesn't.

So I changed all my implementation to send messages to Facebook without using with link parameters for all posts, with or without links.

With link Parameter - throws error #1500

FacebookType publishMessageResponse = resftFBclient.publish(FACEBOOK_PAGE_ID 
+"/feed", FacebookType.class, Parameter.with("message", "Hello StackOverFlow!"),
Parameter.with("link", "message with a link , www.me.com"));

With no link parameter - this works even if message contained URL/link

FacebookType publishMessageResponse = resftFBclient.publish(FACEBOOK_PAGE_ID. +
"/feed",FacebookType.class,Parameter.with("message", "My message"));

This works even if message contained URL/link and it creates an clickable link on FB. Could it be that FB is trying to drop the link implementation and letting us figure it out that the former works just as the link implementation? What's the difference anyways?

That's brutal!

Cheers

Babajide

Miserable answered 22/5, 2013 at 8:32 Comment(2)
yeah this seems to apply to me. when i remove link it works..crazyJudithjuditha
It works, but we lose the nice formatting of links (which is still better than no post at all however).Edmee
O
0

I was trying to solve this problem this problem that seems to be occurring to almost everyone. I am using the PHP SDK.

What I noticed is that it always returned this error for the first time I tried to post the link. On a second try, it was posted with success.

Really hackishly I then checked for an error and retried to post to the wall.

$errorCount = 0;

function postPicture($phrase)
{
    try
    {
      $image = $_SESSION['photoLink'];
      $facebook->setFileUploadSupport(true);
      $response = $facebook->api(
        '/me/feed',
        'post',
        array(
          'message' => $phrase,
          'picture' => 'http://mylink/pictures/facebook.png',
          'link' => $image,
          'caption' => 'My caption',
          'description' => 'My description', 
          'type' => 'photo',
          'name' => 'My name'
        )
      );

      echo 'Success';
      }

    }
    catch (FacebookApiException $e)
    {
      // You really should check if this $error is #1500 before doing that. I didn't :)
      if($errorCount < 2)
      {
        postPicture($phrase);
        $errorCount++;
      }
      else
      {
          $e = str_replace('"', "", $e);
          $e = str_replace("'", "", $e);
          echo 'Error ' . $e;
      }
   }
}
Octofoil answered 23/7, 2013 at 20:23 Comment(0)
O
0

To solve these problems just make sure you add these og metadata tags in the head section of the page represented by the url you want to share:

<meta property="og:type" content="article" /> //or any other type like blog, website etc....
<meta property="og:url" content="your article url here" />
<meta property="og:title" content="your article title here" />

Good luck!

Oxyacid answered 14/11, 2013 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.