2017-04-16 6 views
-1
abgelaufen
<?php 
    require_once("facebook.php"); // set the right path 

    $config = array(); 
    $config['appId'] = ''; 
    $config['secret'] = ''; 
    $config['fileUpload'] = false; // optional 
    $fb = new Facebook($config); 

    $params = array(
     // this is the main access token (facebook profile) 
     "access_token" => "EAAHHbZBnyVlsBAFx1X4LVrxouuTYZB5IDsd7PI2FQica9tqNNvzInPKP9KHPQKJPfxITGy6ZCuSjOFPChrD4f5damVXSeC2O6w7BZATUNp7s8nTZBVn8ZBdyKuVpbQeTU4mZBVrUJ92IUwP7Ubli9JJuUrtqZAwOe1ZCv751ZBNOoO80fXyATn0ztaU8OQZD", 
     "message" => "", 
     "name" => "", 
     "caption" => "", 
     "description" => "" 
    ); 

    try { 
     $ret = $fb->api('/me/feed', 'POST', $params); 
     echo 'Successfully posted to Facebook Personal Profile'; 
    } catch(Exception $e) { 
     echo $e->getMessage(); 
    } 
    ?> 

Ich habe eine serverseitige PHP-Anwendung erstellt, die Beiträge Status automatisch auf meiner FB-Seite, aber wenn ich die App laufen, es wird eine Fehlermeldung angezeigt:Fehler beim Überprüfen der Zugriffstoken: Session hat

Error validating access token: Session has expired 
+0

Entfernen Snippet und verwandte App, gaben Sie uns Ihre Token: < –

+0

Vielleicht kann dieser Beitrag für Sie nützlich sein: http://StackOverflow.com/Questions/13953265/Facebook-Non-Expiring-Access-Token?rq = 1 – Tjoene

+0

[Im Allgemeinen] (https://developers.facebook.com/docs/facebook-login/access-tokens) Ihr Zugriffstoken ist nicht statisch, Sie müssen etwas über oauth lernen oder zumindest sdk auf angemessene Weise verwenden . –

Antwort

0
<?php 
// require Facebook PHP SDK 
// see: https://developers.facebook.com/docs/php/gettingstarted/ 
require_once("facebook.php"); 

// initialize Facebook class using your own Facebook App credentials 
// see: https://developers.facebook.com/docs/php/gettingstarted/#install 
$config = array(); 
$config['appId'] = ''; 
$config['secret'] = ''; 
$config['fileUpload'] = false; // optional 

$fb = new Facebook($config); 

// define your POST parameters (replace with your own values) 
$params = array(
    "access_token" => "EAAHHbZBnyVlsBAFx1X4LVrxouuTYZB5IDsd7PI2FQica9tqNNvzInPKP9KHPQKJPfxITGy6ZCuSjOFPChrD4f5damVXSeC2O6w7BZATUNp7s8nTZBVn8ZBdyKuVpbQeTU4mZBVrUJ92IUwP7Ubli9JJuUrtqZAwOe1ZCv751ZBNOoO80fXyATn0ztaU8OQZD", // see: https://developers.facebook.com/docs/facebook-login/access-tokens/ 

    "message" => "", 
    "link" => "", 
    "picture" => "", 
    "name" => "How to Auto Post on Facebook with PHP", 
    "caption" => "", 
    "description" => "Automatically post on Facebook with PHP using Facebook PHP SDK. How to create a Facebook app. Obtain and extend Facebook access tokens. Cron automation." 
); 

// post to Facebook 
// see: https://developers.facebook.com/docs/reference/php/facebook-api/ 
try { 
    $ret = $fb->api('/YOUR_FACEBOOK_ID/feed', 'POST', $params); 
    echo 'Successfully posted to Facebook'; 
} catch(Exception $e) { 
    echo $e->getMessage(); 
} 
?> 

Versuchen Sie dies .... http://www.pontikis.net/blog/auto_post_on_facebook_with_php Fügen Sie Ihre AppId, Secret Key.

Verwandte Themen