PHP - Obtaining Facebook Album Pictures
Similar TutorialsHi there, Can you guys/girls tell me if this is even possible: - take pictures with eye-fi card in the camera, which uploads the images to a server - on the server, automatically add a watermark, and post them on 3 different facebookpages Hello everyone, I'm new here
My website was working fine until a few days ago, Up until then my str_replace('s130x130', 's800x800') and str_replace('_s', '_o') solved the picture thing. Now the images are broken (or very small) and I can find no documentation on how to enlarge the pictures. Thus my question: how do I retrieve larger pictures from the Facebook PHP SDK?
Code
foreach($pagefeed['data'] as $post) { if ($post['type'] == 'status' || $post['type'] == 'link' || $post['type'] == 'photo') { if ($post['type'] == 'photo') { echo "<div class='col-md-6 col-sm-6'>"; echo "<div class='thumbnail'>"; echo "<img src=" . str_replace('s130x130', 's800x800', str_replace('_s', '_o', $post['picture'])) . " />"; echo "<div class='caption'>"; echo "<sup>Geplaatst op: " . date("d-m-Y, (strtotime($post['created_time']))) . "</sup>"; if (empty($post['message']) === false) { echo "<p><span class='glyphicon glyphicon-comment'></span> " . $post['message'] . "</p>";} echo "</div>"; echo "</div>"; echo "</div>"; $i++; } } }Thanks in advance! i do think is a small mistake i making can u please have a look if u can ok here's the problem i am trying to delete an album within the album should also delete the photos related to that album this what i tried gives this error Delete image failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 my tables are table albums fields album_id, album_name, album_owner, sub_album table photos fields, photo_id, photo_name, photo_extension, photo_proper photo_owner, photo_date, photo_comments, photo_size, album_id photo_proper is the name image stored in folder <?php define('ROOT_DIR', './'); define('PROPER', TRUE); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); // No album id has been selected if (isset($_GET['albums'])) // get the album name since we need to display // a message that album 'foo' is deleted $result = mysql_query("SELECT album_id, album_name, album_owner, sub_album FROM albums WHERE album_id = $album_id") or die('Delete image failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $album_id = $row['album_id']; $album_name = $row['album_name']; // get the image filenames first so we can delete them // from the server $result = mysql_query("SELECT photo_id, photo_id FROM photos WHERE album_id = $album_id") or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { define("GALLERY_IMG_DIR", "./photos/"); unlink(GALLERY_IMG_DIR . $row['photo_proper']); unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']); } $result = mysql_query("DELETE FROM photos WHERE album_id = $album_id") or die('Delete image failed. ' . mysql_error()); $result = mysql_query("DELETE FROM album WHERE album_id = $album_id") or die('Delete album failed. ' . mysql_error()); // album deleted successfully, let the user know about it echo "<p align=center>Album '$album_name' deleted.</p>"; } else { echo "<p align=center>Cannot delete a non-existent album.</p>"; } ?> try 2 error line 5 <?php define('ROOT_DIR', './'); define('PROPER', TRUE); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); // No album id has been selected if (isset($_GET['albums'])) { // get the image file name so we // can delete it from the server $sql = "SELECT album_id, album_name, album_owner, sub_album FROM albums WHERE album_id = {$_GET['albums']}"; $result = mysql_query($sql) or die('Delete photo failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); // get the image filenames first so we can delete them // from the server $sql = "SELECT photo_id, photo_proper FROM photos WHERE photo_id = {$_GET['photos']}"; $result = mysql_query($sql) or die('Delete photo failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); define("GALLERY_IMG_DIR", "./photos/"); // remove the image and the thumbnail from the server unlink(GALLERY_IMG_DIR . $row['photo_proper']); unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']); // and then remove the database entry $sql = "DELETE FROM photos WHERE photo_id = {$_GET['photos']}"; $result = mysql_query("DELETE FROM album WHERE album_id = $album_id") or die('Delete album failed. ' . mysql_error()); // album deleted successfully, let the user know about it echo "<p align=center>Album '$album_name' deleted.</p>"; } else { echo "<p align=center>Cannot delete a non-existent album.</p>"; } } } ?> try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
Hi guys, I am searching for the definitive way of obtaining the root directory of my app. I need to it to work on localhost and also on ALL platforms, NIX, Windows etc. I would like to do this as I wish to use it to locate all my sub directory files - includes, model etc. For example, I may have this as my landing page: http://www.mywebsite.com/index.php The root directory might be: html The index.php might reside he html/index.php ... but my includes files might be he html/lib/includes So I would be looking to obtain the root in an absolute kind of way to allow me to string together the includes sub directory in a relative kind of way. In summary then: 1. How to obtain the root with 100% percent success, all of the time on all platforms. 2. How to string the sub directory together with 100% percent success, all of the time on all platforms. 3. Any comments on this as an approach, also welcome. Many thanks in advance, S I have a website that a user fills out there login information which we then post to another website outside of our system. The website where the information is being posted is doing an IP check. They are trying to check for our server IPs instead of the users IPs. Since the POST is coming from the user, there is no way to get the server IP (that I know of...right?). As a work around for this, I'm trying to initially post to another script on our server which will then repost the information using PHP. This way the IP will be from our server instead of the user. I've tried using curl, and while that allows me to pull the content of the webpage, it does not redirect the user to the page after the login. I've also tried using header() but I'm pretty sure that solution will not work either. So does anyone know how I can send post information to a website on my server using php and have it send the user to the resulting page? Thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=326412.0 I was not sure on which board to put this thread, so please move it if there is a more appropriate board. I am wanting to create a website that displays images which I have put into a database. I would like the number of images on one page not to exceed 10, for example, and when the number of images in the database exceeds this number, a new page will be created. I would like it to function similar to Google Images where the number of pages is dictated by the number of images in the database. I cant figure out how to achieve this, so any pointers or thoughts would be great Thanks, Matlab Hello, There is something wrong with my statement it is not returning sql queries results based on matching the url based based userid to match with the table user_id and get the Ablum id and Album name: Please hlep: Code: [Select] if(isset($_GET['userid'])) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $id = $user->id; $album_id = $_GET['userid']; $query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $album_id; //$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ; $result = mysql_query($query) or die('Error, No Album Search failed'); list($name, $user_id, $id, $year) = mysql_fetch_array($result); echo $id; //exit; } if you have the urls to pictures in a database how would you display the actual pictures on a webpage? Here 's the code. Code: [Select] <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> td { border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #30C; border-right-color: #30C; border-bottom-color: #30C; border-left-color: #30C; } </style> </head> <body> <?php navBar(); echo "<form action=\"\" method=\"post\" name=\"catalog\">"; DatabaseConnection(); $query = "SELECT * FROM treats"; $result_set = mysql_query($query) or die(mysql_error()); $i = 0; echo "<table>"; while ($row = mysql_fetch_array($result_set)) { echo"<tr><td width=\"400px\">($row['product_pic']). <br />{$row['product_id']}.<br />{$row['product_title']}.<br /> {$row['product_Description']}.<br />{$row['product_price']}</td></tr>"; } echo "</table>"; ?> </form> </body> </html> Hi, i would like to know what is the best method to store a picture. Currently what happens, is each user has a different avatar, which when uploaded comes in a folder called Avatar, in my website folder and is also stored as a BLOB in mysql. I would like to know is this ok to store all avatars in one folder or some other step should be used and if so could some one guide me to a good tutorial. As I would also like to make an option, where people could upload their pictures, is it safe to store pictures in the same folder for all users or some how create a different folder for each user. Hello, like I promised, I'm back with another problem. This one will be harder xD so squeeze your brain
Now I've got a webpage, with a database shown into a table, under that I've got page numbers. So I got my 20 rows for each page.
https://www.dropbox..../stillnotok.jpg
Great/awesome so far
Now I've got a new problem and it's hard for me to explain this too.
In my database I got allot of tables, in my webpage I'm using 2 of them, called 'artikel' and 'images".
Everything from my artikel table is ok. So we don't need to look at that.
But my problem is with the table 'images'.
In that table I got 2 items.
Like you will see in my code, I need the I_ARTCODE and I_FILE
in I_ARTCODE stands: 14 and for the other image 15
in I_FILE stands: 5.jpg and for the other image 6.jpg
With the code I've got now, I display the word 5.jpg and 6.jpg.
But I need to display the picture behind that, the person who gave me this task sayed, I normally can do this with the pad but it's not a real url, I'll give you guys a picture how my database looks like:
https://www.dropbox....uqplxd/path.jpg
Over here the pad is this: 000000-001000
It doesn't seems normal to me and I can't find a sollution for this on the internet.
Can someone plz help me?
Ooh ya, almost forgot, this is my code:
<?php include('connect-mysql.php'); if (!empty($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 20; $sqlget = "SELECT * FROM artikel, images LIMIT $start_from, 20 "; $sqldata = mysqli_query($dbcon, $sqlget) or die('error getting'); echo "<table>"; echo "<tr><th>A_ARTCODE</th><th>A_NUMMER</th><th>A_OMSCHRN</th><th>A_REFLEV</th><th>A_WINKEL</th><th>I_ARTCODE</th><th>I_FILE</th></tr>"; while($row = mysqli_fetch_array($sqldata)){ echo "<tr><td align='right'>"; echo $row['A_ARTCODE']; echo "</td><td align='left'>"; echo $row['A_NUMMER']; echo "</td><td align='left'>"; echo $row['A_OMSCHRN']; echo "</td><td align='left'>"; echo $row['A_REFLEV']; echo "</td><td align='right'>"; echo $row['A_WINKEL']; echo "</td><td align='right'>"; echo $row['I_ARTCODE']; echo "</td><td align='right'>"; echo $row['I_FILE']; //echo "<img src='000000-001000".$row['I_ID']."' />"; echo "</td></tr>"; } echo "</table>"; $sql = "SELECT COUNT(A_ARTCODE) FROM artikel"; $rs_result = mysqli_query($dbcon, $sql) or die ("mysqli query dies"); $row = mysqli_fetch_row($rs_result) or die ("mysqli fetch row dies"); $total_records = $row[0]; $total_pages = ceil($total_records / 20); for ($i=1; $i<=$total_pages; $i++) { echo "<a href='index.php?page=".$i."'>".$i."</a> "; }; ?> Hi,
I have a crwal engine and every time when I try to take a picture from a specific website, it also take some bullshit from superfish, creating iframe and div class, that I can`t deleted using jquery after my page is load.
I was looking in my code and I found out that the only thing that trigger that is the <img src="<?php h(getPicture($itemRow['site'], if I remove 'site', I don`t see any other superfish code but also don`t see the picture. What can I do to take only the .jpg picture , without any of the other crap?
<?php for ($i = 0; $i < count($itemRow['pics']); $i++) { ?> Hello. I'm working on a website with an editor that allows image uploading. Ideally I want to be able to develop a framework for this and use it in later projects. What I have in mind is this: Database has an images table Entries contain these fields: id, filename, and a short description Images are referred to by their ids in other parts of the application. That part seems simple to me, but now there are two details I need to determine: the file name, and storing the images. Big sites like Facebook - as far as I know - parse uploads and store them all in the same format. I can see the huge security benefit there. What are the best ways of doing that? As for the file name, I know PHP has a function to generate a file with a unique name. Is there any benefit to doing that over using the id? (i.e. 1.jpg, 2.png, 3.jpg, etc) Hi, I cant quite figure out how to assign an unique id to the picture I upload to my page, all help would be appreciated. Here's the upload code: //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) ; mysql_select_db("Database_Name") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Hello there, I am working on a pagination script and have hit a bit of a wall. Here is the script: Code: [Select] <?php include("header.php"); ?> <?php $host = "localhost"; // $user = ""; //username to connect to database $pass = ""; //password to connect to database $db = ""; //the name of the database mysql_connect($host,$user,$pass) or die("ERROR:".mysql_error()); mysql_select_db($db) or die("ERROR DB:".mysql_error()); $max = 25; //amount of articles per page. $p = $_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view the article! if(isset($_GET['act']) && $_GET['act'] == "view") { $id = $_GET['id']; $sql = mysql_query("SELECT * FROM 3dpics WHERE id = '$id'"); while($r = mysql_fetch_array($sql)) { $title = $r['title']; $url = $r['url']; echo "<div align='center'><img src='$url' width='500' height='500'><br />$title<br /><br /><a href='test.php'>Back</a></div>"; } }else{ //view all the articles in rows $sql = mysql_query("SELECT * FROM 3dpics LIMIT ".$limits.",$max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM 3dpics"),0); $totalpages = ceil($totalres / $max); echo "<table name='myTable' cellpadding='5' cellspacing='5'>"; echo "<tr>"; //the table while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $url = $r['url']; echo "<div id='piccontentalign' align='center'>"; echo "<td><img src='$url' width='225' height='225'><br /><div align='center'><a href='test.php?act=view&id=$id'>$title</a></div></td>"; } echo "</tr></table></div>"; //close up the table for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='test.php?p=$i'>$i</a>|"; } } ?> All this does is pull the url's of the images out of the database. But, it all shows up on 1 line across the screen! I tried echoing the rows instead, but then it just shows up as 1 line going horizontal. So i'm trying to figure out a way to get 5 pictures per row. This is the code that displays them on the main page: Code: [Select] echo "<table name='myTable' cellpadding='5' cellspacing='5'>"; echo "<tr>"; //the table while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $url = $r['url']; echo "<div id='piccontentalign' align='center'>"; echo "<td><img src='$url' width='225' height='225'><br /><div align='center'><a href='test.php?act=view&id=$id'>$title</a></div></td>"; } echo "</tr></table></div>"; //close up the table Thanks for all your help! I want to display pictures in a table using a PHP loop or something, for example 3 pictures in one row, and then when that row has filled, move to the next row, So I can have a grid of pictures, (similar to that on facebook, when your viewing photo albums)... But I've no idea how to do it! I need some help working through this. I have an uploader for files, but I'd like it to create a link of the file uploaded and automatically post it to a page. Each user has a profile page and I'd like these pictures to be posted to their profile page. I guess with a session, it would take the logged in username and post the pictures uploaded on the page " member_profile2.php?username=xxxx " Here is my upload file for reference. uploads.php Code: [Select] <?php $Dir = "temporary"; if (isset($_POST['upload'])) { //if file uploaded if (isset($_FILES['new_file'])) { //if successful if (move_uploaded_file($_FILES['new_file']['tmp_name'], $Dir . "/" . $_FILES['new_file']['name']) == TRUE){ chmod($Dir . "/" . $_FILES['new_file']['name'], 0644); echo "<b>File \"" . htmlentities($_FILES['new_file']['name']) ." was successfully uploaded </b><br />\n"; //displays file info echo "Name: ". htmlentities($_FILES['new_file']['name']) . "<br />". "Size: " . $_FILES['new_file']['size'] . " bytes" . "<br />". "Type: " . $_FILES['new_file']['type']; } //if not successful else { echo "<b>Uploading \"" . htmlentities($_FILES['new_file']['name']) . " was unsuccessful</b><br />\n"; } } } ?> <form action="uploads.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="250000" /><br /> Select file to upload:<br /> <input type="file" name="new_file" /> 250kB limit!<br /> <input type="submit" name="upload" value="Upload File" /><br /> </form> ?> and my member_profile2.php Code: [Select] <?php /*?><?php error_reporting(E_ALL ^ E_NOTICE); ?><?php */?> <?php # Starting the session session_start(); # Requiring SQL connection require_once 'mysql-connect2.php'; # Setting auser as SESSION['user'] $auser = $_SESSION['user']; # SQL protecting variables $username = (isset($_GET['username']))?mysql_real_escape_string($_GET['username']):$username; # Checking through each query if(isset($auser)) { $sql = mysql_query("SELECT * FROM `user` WHERE `username` = '$username'"); if(mysql_num_rows($sql)) { while($row = mysql_fetch_array($sql)) { $page = "<h1>User Info</h1>". "<b>Username: {$row['username']}<br /><br />". "<b>First Name: {$row['firstname']}<br /><br />". "<b>Last Name: {$row['lastname']}<br /><br />". "<b>Email: {$row['email']}<br /><br />". "<form name=\"backlistfrm\" method=\"post\" action=\"members2.php\">". " <input type=\"submit\" value=\"Back to The List\">". "</form><br />"; } } else { $page = "ERROR: No member found for username: <strong>{$_GET['username']}</strong>."; } } else { $page = "ERROR: Not logged in."; } # Printing the final output print $page; ?> I'd like the pictures to be displayed after the user details. Any help with this would be great. I was also thinking, could I just have the uploader save it as a filename with the user's username? For example, "user1-image1.jpg". And then have their profile page pull and display any files with the name user1-image1-10.jpg (10 being max possible uploads for that user). How would I do this? This sounds maybe easier. Hi guys, A beginner at php/mysql here... For a project I'm doing, I would like to display search results with an image, small description, then a 'read more' link. After googling this issue, I can't find much information on it, which surprised me. Someone did mention blobs for images... (whatever they are!) I'm wondering if anyone knows of any tutorials, or has any code to do this? Your help is much appreciated. Thanks. |