php - facebook Graph API for photo got object ID not exist -
i'm creating plugin wordpress dealing facebook feed. , following tutorials https://www.codeofaninja.com/2014/10/display-facebook-page-feed-on-wordpress-or-website.html
here code in views.
$ct_facebook_keys = get_option("ct_facebook_keys"); $access_token_url = "https://graph.facebook.com/oauth/access_token?client_id=".$ct_facebook_keys["app_id"]."&client_secret=".$ct_facebook_keys["app_secret"]."&grant_type=client_credentials"; $result = file_get_contents($access_token_url); $decoded = json_decode($result, true); $access_token = $decoded["access_token"]; $profile_photo_src = "https://graph.facebook.com/".$ct_facebook_keys["fb_user_id"]."/picture?type=square"; $fields = "id,message,picture,link,name,description,type,icon,created_time,from,object_id"; $json_link = "https://graph.facebook.com/".$ct_facebook_keys['fb_user_id']."/feed?access_token=".$access_token."&fields=".$fields."&limit=".$limit; $json = file_get_contents($json_link); $obj = json_decode($json, true); $feed_item_count = count($obj['data']); <?php for($x=0; $x<$feed_item_count; $x++){ // post id $id = $obj['data'][$x]['id']; $post_id_arr = explode('_', $id); $post_id = $post_id_arr[1]; // user's custom message $message = $obj['data'][$x]['message']; // picture link $picture = $obj['data'][$x]['picture']; $picture_url_arr = explode('&url=', $picture); $picture_url = urldecode($picture_url_arr[1]); // link posted $link = $obj['data'][$x]['link']; // name or title of link posted $name = $obj['data'][$x]['name']; $description = $obj['data'][$x]['description']; $type = $obj['data'][$x]['type']; // when posted $created_time = $obj['data'][$x]['created_time']; $converted_date_time = date( 'y-m-d h:i:s', strtotime($created_time)); $ago_value = time_elapsed_string($converted_date_time); // $page_name = $obj['data'][$x]['from']['name']; // useful photo $object_id = $obj['data'][$x]['object_id']; ?> <li class="feed-list-item"> <div class='row'> <div class='col-md-4'> <div class='profile-info'> ..... </div> </div> <div class='col-md-8'> <div class='profile-message'><?php echo $message ?></div> <div class='post-content'> <a href='<?php echo $link ?>' target='_blank' class='post-link'> <?php if($type=="photo"){ ?> <?php var_dump("https://graph.facebook.com/".$object_id."/picture"); ?> <img src='https://graph.facebook.com/<?php echo $object_id ?>/picture' /> <?php } <div class='post-info'> <div class='post-info-name'><?php echo $name ?></div> <div class='post-info-description'><?php echo $description ?></div> </div>"; <?php } ?> </a> </div> </div> </div> </li> <?php } ?>
the issue line https://graph.facebook.com/<?php echo $object_id ?>/picture
variable $object_id
. think not correct. when tried access example return of code https://graph.facebook.com/10211788176158739/picture
. result:
{ "error": { "message": "unsupported request. object id '10211788176158739' not exist, cannot loaded due missing permissions, or not support operation. please read graph api documentation @ https://developers.facebook.com/docs/graph-api", "type": "graphmethodexception", "code": 100, "error_subcode": 33, "fbtrace_id": "f9xgpm+yqxl" } }
does have idea this? want retrieve image path of facebook posted photos of feed.
thanks in advance...
Comments
Post a Comment