Search code examples
facebookfacebook-graph-apifacebook-likefacebook-javascript-sdkfacebook-c#-sdk

Include a picture in a wall post using the Graph api explorer tool


Is there any way to post a picture? I found references on how to post it from own apps, but what about using the Graph api explorer tool? Btw, I'm not trying to upload a picture, I want to show a picture that's being stored on my server, directly in the post.

Edit1:

      $graph_url = "https://graph.facebook.com/".$_POST['group_id']."/feed";

  $postData = array(
    'access_token' => $_POST['token'], 
    'message' => $_POST['message'],
    'picture' => 'http://admin.oceaniatravel.ro/Files/Pictures/Images/iberostar-paraiso-maya-5-419.jpg');

  $ch = curl_init();
  curl_setopt_array($ch, array(
  CURLOPT_URL => $graph_url,
  CURLOPT_POSTFIELDS => $postData,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_VERBOSE => true
  ));
  $result = json_decode(curl_exec($ch));
  curl_close($ch);

Edit2

The problem was that I was using the graph explorer. A really easy solution is to create an own app and when you generate the token in the explorer app you just choose your own app. Thank you!


Solution

  • The problem with your error

    (#100) The post's links must direct to the application's connect or canvas URL.
    

    Was the fact, that you were using the access token generated through Graph Explorer. Which has its settings for Stream Post Url Security as enabled so that User may not use the Graph explorer for malicious purposes.

    So, to solve the issue, create a new app, which as its default setting gets Stream Post Url Security as disabled, and then through Graph Explorer use the access token corresponding to your own app instead of Graph Explorer.