2011-09-05 3 views
1

Je lis les instructions: Upload Photo To Album with Facebook's Graph APIà Facebook Transfert de l'image en utilisant PHP Curl

Mais bien que je suis les instructions, l'image ne peut pas être téléchargée sur FB. Voici mon code. Aidez-moi, s'il vous plaît.

$graph_url = "https://graph.facebook.com/". $album_id . "/photos?access_token=" . $access_token; 

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_HEADER, false); 
    curl_setopt($ch, CURLOPT_VERBOSE, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_URL, $post_url); 

$post_array = array(
     "source" =>"@". realpath("photo.jpg"), 
     "message"=>"Upload " . date('Y-m-d h:i:s') 
    ); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch); 
$graph_url = "https://graph.facebook.com/". $album_id . "/photos?access_token=" . $access_token; 

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_HEADER, false); 
    curl_setopt($ch, CURLOPT_VERBOSE, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_URL, $post_url); 

$post_array = array(
     "source" =>"@". realpath("photo.jpg"), 
     "message"=>"Upload " . date('Y-m-d h:i:s') 
    ); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch); 
+2

"image ne peut pas être téléchargée sur FB". Pourquoi pas? Avez-vous des erreurs? – CodeCaster

+0

Avez-vous réussi à le faire? – user3697768

Répondre

0

Essayez ceci et voir le résultat:

echo realpath("photo.jpg") 

-t-il vous revenir le bon chemin?

Essayez avec /photo.jpg ou ./photo

+0

J'essaie la même méthode pour publier l'image sur fb. J'ai vérifié le chemin venant de realpath et c'est correct, mais curl retourne la chaîne vide. une idée? – dvdmn

Questions connexes