Php-graph-sdk: auto post problem

Created on 20 Jan 2017  路  4Comments  路  Source: facebookarchive/php-graph-sdk

hi, tnx for reading carefully.
i use api like this:

require_once "Facebook/autoload.php";
        $fb = new Facebook\Facebook([
            'app_id' => 'xxxxxxx',
            'app_secret' => 'xxxxxxxxx',
            'default_graph_version' => 'v2.2'
        ]);
$pageAccessToken = 'xxxxxxxxxxxxxxxxxxxxx';

        $linkData = [
            'link' => $link,
            'message' => $message,
            'picture' => $pic
        ];

        try {
            $response = $fb->post('/me/feed', $linkData, $pageAccessToken);
        } catch (Facebook\Exceptions\FacebookResponseException $e) {
            echo 'Graph returned an error: ' . $e->getMessage();
        } catch (Facebook\Exceptions\FacebookSDKException $e) {
            echo 'Facebook SDK returned an error: ' . $e->getMessage();
        }
        $graphNode = $response->getGraphNode();

my problem is that, this code work sometimes, not all time. and in sometime i see these errors:

Severity: Notice
Message: Undefined offset: 1
Filename: Http/GraphRawResponse.php
Line Number: 108

and

Severity: 4096
Message: Argument 4 passed to Facebook\FacebookResponse::__construct() must be of the type array, null given, called in /home/deponews/public_html/application/controllers/Facebook/FacebookClient.php on line 225 and defined
Filename: Facebook/FacebookResponse.php
Line Number: 75

i go to api explorer , and select my page from drop down and at the bottom drop down , select access page token , then select my page name again. and copy generation token into my page access token.

i don't know why sometimes this code work well , and sometimes its not.

any idea ?

Most helpful comment

This is a problem in 5.5 branch of php-graph-sdk.
Caused by incorrectly parsing the status when HTTP2 is used: HTTP/2 200 is not recognised by the regex at Facebook/Http/GraphRawResponse.php: 107.
Meanwhile, to fix it, I'm currently using: |HTTP/\d\.?\d?\s+(\d+)\s+.*| instead of the standard reg-ex at the above line

@yguedidi this should be re-opened and fixed.
@facebook-github-bot reopen

All 4 comments

Thank you for using the Facebook PHP SDK!

If you need help about using it, you should ask your questions on StackOverflow and tag them with the facebook-php-sdk tag.

So I'm closing this, but if you found a bug in the SDK or think about a feature, feel free to open a new GitHub issues.

I have same Notice:

Undefined offset: 1 in ..../vendor/facebook/graph-sdk/src/Facebook/Http/GraphRawResponse.php on line 108

Please help me.

I have same Notice:

Undefined offset: 1 in ..../vendor/facebook/graph-sdk/src/Facebook/Http/GraphRawResponse.php on line 108

This is a problem in 5.5 branch of php-graph-sdk.
Caused by incorrectly parsing the status when HTTP2 is used: HTTP/2 200 is not recognised by the regex at Facebook/Http/GraphRawResponse.php: 107.
Meanwhile, to fix it, I'm currently using: |HTTP/\d\.?\d?\s+(\d+)\s+.*| instead of the standard reg-ex at the above line

@yguedidi this should be re-opened and fixed.
@facebook-github-bot reopen

Was this page helpful?
0 / 5 - 0 ratings