Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.17 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Posting a photo to facebook page posts to my profile instead
  2. $graph_url = "https://graph.facebook.com/" . $page_id .  "?fields=access_token&access_token="
  3.        . $params['access_token'];
  4.        
  5. $post_url = 'https://graph.facebook.com/'. $page_id .'/photos';
  6.        
  7. function message($data,$token,$url)
  8. {  
  9.     // need token
  10.     $data['access_token'] = $token;
  11.  
  12.     // init
  13.     $ch = curl_init();
  14.  
  15.     curl_setopt($ch, CURLOPT_URL, $url);
  16.     curl_setopt($ch, CURLOPT_POST, 1);
  17.     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  18.     curl_setopt($ch, CURLOPT_VERBOSE, 1);
  19.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  20.  
  21.     // execute and close
  22.     $return = curl_exec($ch);
  23.     curl_close($ch);
  24.  
  25.     // end
  26.     return $return;        
  27. }              
  28.  
  29.  
  30.      $page_access_token = $params['access_token'];
  31.  
  32.      $post_url = 'https://graph.facebook.com/'. $page_id .'/photos';                
  33.  
  34.      print_r($post_url); echo("<br><br>");      
  35.      print_r($params['access_token']); echo("<br><br>");
  36.  
  37.         //echo( message(array( 'source' => '@que/xjy7M.png' ) , $page_access_token, $post_url ));
  38.  
  39.         echo( message(array( 'source' => '@que/1.jpg') , $page_access_token, $post_url ));
  40.  
  41.  
  42.     }