2011-07-24 2 views
0

j'ai problème ... Je ne suis this site ... Je ne suis pas bon à API facebook .. désolé im noobs vraiment avec l'API ..facebook publier flux

mon code:

<?php 


define('FB_APIKEY', '***************************'); 
define('FB_SECRET', '***************************'); 
define('FB_SESSION', '***************************'); 

require_once 'facebook-platform/php/facebook.php'; 

echo "post on wall"; 
echo "<br/>"; 

try { 
$facebook = new Facebook(FB_APIKEY, FB_SECRET); 
$facebook->api_client->session_key = FB_SESSION; 
$facebook->api_client->expires = 0; 
$message = 'testasdfsadf'; 

$attachment = array(
'name' => $_POST["name"], 
'href' => $_POST["href"], 
'description' => $_POST["description"], 
'media' => array(array('type' => 'image', 
'src' => $_POST["src"], 
'href' => $_POST["href"]))); 

$action_links = array(array('text' => 'TITLE', 'href' => 'http://www.mysite.com')); 

$attachment = json_encode($attachment); 
$action_links = json_encode($action_links); 

$target_id = "2410160********"; 
$session_key = FB_SESSION; 


    if($facebook->api_client->stream_publish($message, $attachment, $action_links, null, $target_id)) { 
    echo "Added on FB Wall"; 
    } 
    } catch(Exception $e) { 
    echo $e . "<br />"; 
    } 
?> 

I a obtenu l'erreur:

post on wall 
exception 'FacebookRestClientException' with message 'The user hasn't authorized the application to perform this action' in /Users/*****/Sites/FacebookTEST/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /Users/******/Sites/FacebookTEST/facebook-platform/php/facebookapi_php5_restlib.php(916): FacebookRestClient->call_method('facebook.stream...', Array) #1 /Users/******/Sites/FacebookTEST/index.php(46): FacebookRestClient->stream_publish('testasdfsadf', '{"name":null,"h...', '[{"text":"TITLE...', NULL, '2410160********') #2 {main} 
+0

Avez-vous suivi l'étape intitulée «Autoriser l'application pour publier sur votre mur»? – Mike

+0

yep j'ai trouvé réponse ... utiliser le lien pour autoriser .. – user453089

+0

Cet article est vraiment ** VRAIMENT ** vieux! Essayez de vérifier le [dernier] (https://github.com/facebook/php-sdk) SDK puis ajoutez le code dans mon [article] (http://www.masteringapi.com/tutorials/how-to-post- un-message-sur-l'utilisateur-mur-en-utilisant-facebook-graph-api/33 /) à [example.php] (http://github.com/facebook/php-sdk/blob/master/examples /example.php) du SDK. – ifaour

Répondre

0

J'ai trouvé réponse:

ici solution: http://www.facebook.com/connect/prompt_permissions.php?api_key=& YOUR_API_KEY v = 1,0 & next = http: //www.facebook.com/connect/login_success.html xxRESULTTOKENxx & & display = Page ext_perm = publish_stream, offline_access & & enable_profile_selector = 1 profile_selector_ids =

ID_OF_YOUR_PAGE

Insérez votre clé API et l'ID de page dans le texte GRAS.