Search code examples
phpfacebookweb-scrapingfacebook-php-sdkachievements

Achievements rescrape fail. Error #3403 Achievement hasn't been Registered


Let me start by saying that this is an established app with 51 established achievement that were all working for the past couple of years until a few days ago.

I believe I created this mess by making some small changes to the page scraped by the Facebook achievements system. The achievement urls themselves have not changed but my error logs alerted me to a spelling mistake in the og:url tag so I rectified it, along with the corresponding file name.

Fastidiousness does not pay it seems.

Since then whenever the system attempts to award an achievement, I get the error:

E: (#3403) Achievement hasn't been registered for this application.

So I tried re-scraping the achievements via the Open Graph Object Debugger and via calls to the API like so:

try{
    $request = new FacebookRequest( $adminSession, 
       'POST', 
        "/?id=". FB_METRO_ACH_URL_BASE . $achievementId . '&scrape=true'
        );
    $response = $request->execute();
}catch .....

I expected to have to do one of those methods anyway after having made changes.

In the object debugger, the scrape goes fine with no warnings. The API re-scrape also goes without a hitch and displays each achievement correctly and in full and with the correct App id.

Taking the unique Id of the achievements and viewing them in the Object Browser also looks fine.

General API calls to display all achievements registered for this app, like this:

try{
    $request = new FacebookRequest( $adminSession, 
        'GET', 
        "/" . APP_ID .   "/achievements"
        );
    $response = $request->execute();
}catch .....

Return the full list as one would expect, no errors or warnings, yet the problem persists.

Naturally I've pulled all the relevant files out of version control and reinstated the originals, forcing another re-scrape along the way, but no dice.

Pulling my hair out now so any advice greatly appreciated.


Solution

  • OK, I've figured this out, basically I had 2 dynamic URLS for achievements achievementDescription.php achievementContent.php

    achievementDescription.php was used to register all achievements with facebook a few years ago. Contained within the meta tags was:

    <meta property="og:url" content="http://example.com/achievementContent.php?aid=<?=$aid?>"/>
    

    The strange thing is that achievementContent.php never actually existed, having been misspelled in the file name at creation. Correcting the matter made Facebook see this as a new achievement it seems.

    With my attempted 'fix' i.e. having a correctly named and located achievementContent.php, I took @Igy's advice and attempted to re-register one of the existing achievements and found that it created a new duplicate achievement linked to the achievementContent.php URL (all pre-existing achievements are linked to achievementDescription.php)

    So, I'm guessing that the scraping procedure has been upgraded at the Facebook end in the interim. The original registration system must have tried to follow the broken link and then just assigned the achievement to the achievementDescription.php URL. Attempting to rescrape the achievement in the newer system, without a valid destination for og:url, caused it to fail.

    Setting the og:url property to self reference achievementDescription.php i.e.

    <meta property="og:url" content="http://example.com/achievementDescription.php?aid=<?=$aid?>"/>
    

    and then re-registering all achievements has caused the Facebook system to start recognizing the achievements again and we are able to award them to players, importantly it has done this without creating duplicate achievements for my app.