Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible/How to save Facebook Post ID to mysql database?
    primarykey
    data
    text
    <p>I have a program (an app) which ask for user input then generate an image and post the image link to FB timeline. now i want to do is to get the POSTID and save it to my database. so i can have a record which i can retrieve if ever i want to connect to the FB POST. how can i do this? below is the code i use for posting to Facebook timeline. Hope you can help me with this. My first time to do such thing. thanks a lot!</p> <pre><code> $http_dir = 'http://site.com/Amats/image_entry/'; $post_link = $http_dir . $img_newname; if (!empty($name) &amp;&amp; !empty($email) &amp;&amp; !empty($office_id) &amp;&amp; !empty($title) &amp;&amp; !empty($story)) { $save_sql = "INSERT INTO `tbl_contest` (filename, name, email, office_id, title, story, time) VALUES ('$img_newname','$name','$email','$office_id','$title','$story','$sql_date')"; $query = mysql_query($save_sql,$con) or die(mysql_error("Could not write information to the database")); if (mysql_num_rows($con) !== 0) { header('Location:' . $uploadSuccess.'#modal-text'); if($user_id) { // We have a user ID, so probably a logged in user. try { $ret_obj = $facebook-&gt;api('/me/feed', 'POST', array( 'link' =&gt; $post_link, 'message' =&gt; 'Posting with the PHP SDK!' )); echo '&lt;pre&gt;Post ID: ' . $ret_obj['id'] . '&lt;/pre&gt;'; // Give the user a logout link echo '&lt;br /&gt;&lt;a href="' . $facebook-&gt;getLogoutUrl() . '"&gt;logout&lt;/a&gt;'; } catch(FacebookApiException $e) { $login_url = $facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'publish_stream' )); echo 'Please &lt;a href="' . $login_url . '"&gt;login.&lt;/a&gt;'; error_log($e-&gt;getType()); error_log($e-&gt;getMessage()); } } else { // No user, so print a link for the user to login $login_url = $facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'publish_stream' ) ); echo 'Please &lt;a href="' . $login_url . '"&gt;login.&lt;/a&gt;'; } } mysqli_close($con); } </code></pre> <p>I tried making something like this. but its not working;</p> <pre><code> $post_id = $ret_obj['id']; $save_id = "INSERT INTO `tbl_mytable` (post_id) VALUES ('$post_id')"; $query = mysql_query($save_id,$con) or die(mysql_error("Could not write information to the database")); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload