PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] FaceBook PHP API SDK: suddenly the argument 'link' is not published and /me/feed is not working

 March 12, 2022     facebook, facebook-graph-api, facebook-php-sdk     No comments   

Issue

I completed this script, that was working fine till this morning, when launching it, suddenly I noticed that the argument "link" of the array $linkData, is not published any longer, (no error returned) while "message" is published.

I also noticed that if I put /me/feed into the object $fb->post, it doesn't work (see the commented line). No errors returned.

While, if I put the code of a group (the code you see is a test group I created to test the script), the argument "message" is published (not the "link")

The scopes are:

user_managed_groups,
user_events,
user_friends,
user_posts,
publish_actions,
user_actions.music,
user_actions.video,
public_profile

The link is referred to the link for which the application is written. the www.example.com URL, is written here for this example. In the real code, I use the URL of the site of the App (that till yesterday was working fine).

Please here the code:

<?php
session_start();

define(__APP_ID__, XXXXXXXXXXXXXXX);
define(__APP_SECRET__, 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY');
define(__APP_TOKEN__, 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ');
define(__APP_ACCESS_TOKEN__, 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW');

require_once '../include/setup.php';
require_once $root_dir.'/include/Facebook/autoload.php';

// Creates the object
$fb = new Facebook\Facebook([
    'app_id' => __APP_ID__,
    'app_secret' => __APP_SECRET__,
    'default_graph_version' => 'v2.2',
]);

$linkData = [
    'link' => 'http://www.example.com',
    'message' => 'The link above, is not any longer published',
];

$group_id = "1041863359178529";

        try {

            //$response = $fb->post("/me/feed", $linkData, __APP_ACCESS_TOKEN__); // SUDDENLY it doesn't work any longer
            $response = $fb->post("/{$group_id}/feed", $linkData, __APP_ACCESS_TOKEN__);

            } catch  (Facebook\Exceptions\FacebookResponseException $e) {
                echo 'Graph returned an error: ' . $e->getMessage();
                exit;
            } catch (Facebook\Exceptions\FacebookSDKException $e) {
                echo 'Facebook SDK returned an error: ' . $e->getMessage();
                exit;
            }

        $graphNode = $response->getGraphNode();
        echo 'Posted with id: ' . $graphNode['id']."\r\n";

?>

EDIT: Is there anything I can do? Is id depending from the App settings? I changed many parameters to find a solution but I still have the issue.


Solution

I did verified that the block, is due FB. In other words: probably of security reasons (mainly Anti-Spam), FB block repetitive use of the function in short time.

I did try also to wait more than 15 seconds among the iterations, but if I employ it for more than 20-25 time in one day, FB suspends all the required authorizations.

At the time I did post the thread, FB was enabling only the post of the text, and deactivated OpenGraph.

Now, instead, it blocks any kind of sending, including text.



Answered By - Tormy Van Cool
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing