rumeye
Members-
Posts
15 -
Joined
-
Last visited
rumeye's Achievements
Newbie (1/5)
1
Reputation
-
I am trying to include the latest post from a tumblr blog in my website, which works fine. I can't figure out how to choose a specific size of photo from the API, such as the 500px photo. <?php $numPosts = 3; $feedURL = "http://jeffhui.tumblr.com/api/read/?num=$numPosts"; $xml = simplexml_load_file($feedURL); foreach($xml->posts->post as $post){ $title = (string) $post->{'regular-title'}; $posts = (string) $post->{'regular-body'}; $photo = (string) $post->{'photo-url'}; $caption = (string) $post->{'photo-caption'}; echo"<h2>".$title."</h2> <p>".$posts."</p> <p><img src=".$photo."></p> <p>".$caption."</p>"; } ?> Some one posted this online and say it has to loop through them like this, but I dont know how to apply the bellow script into my. <?php $xmlResult = file_get_contents($tumblr_url_aktuell); $xml = simplexml_load_file($tumblr_url_aktuell); foreach($xml->posts->post->{'photo-url'} as $photoURL){ if((string)$photoURL['max-width'] == '500'){ $image = $photoURL; } } ?>
-
Thank you it work
-
One last question, in order to print the info of John Doh, I get nothing with the code below: echo $xml->model->name("John Doh")->info; I think i did somthing wrong there.
-
Thanks Barand, that's a better solution for me =)
-
I am not very experience with PHP MYsql database, my website is not run on a database. but I try to make the updating part as simple as I can, by ftp a folder with images and the album name will be the folder name. and you are right this is why things getting so messed up. Maybe I should learn how to create a data base gallery.
-
I guess all I can do at this moment is to add a "-" in between the first and last name. (for now). this is a link in my internal server, might be a bit slow. http://64.56.236.148/iconmodels.ca/women_fashion.php Please find top roll, 3rd image from the left "Alicia-A" is there any way to replace the "-" with a space in the echo''; ?
-
Yes, just when I attempt to add a space in a tag as bellow: <?xml version="1.0" encoding="UTF-8"?> <library> <women_fashion> <Adriana>height 5'10, bust 34, waist 24, hips 35, dress 10, hair brown, eyes green.</Adriana> <Eva>This is the model info of Eva</Eva> <John Doh>This is the model info of John Doh</John Doh> </women_fashion> </library> and I got this error log: Warning: simplexml_load_file() [function.simplexml-load-file]: info.xml:6: parser error : Specification mandate value for attribute Doh in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line18 Warning: simplexml_load_file() [function.simplexml-load-file]: <John Doh>This is the model info of John Doh</John Doh> in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line 18 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line 18 Warning: simplexml_load_file() [function.simplexml-load-file]: info.xml:6: parser error : expected '>' in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line 18 Warning: simplexml_load_file() [function.simplexml-load-file]: <John Doh>This is the model info of John Doh</John Doh> in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line 18 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\xampp\htdocs\Iconmodels.ca\women_fashion.php on line 18 And so far I will need a space in between the tag, because I am using the folder name as the album person name. Are there anyway to do a tag with a space?
-
I see the issue now, because some of my folder name is as follow: <John Doh>This is the model info of Alicia</John Doh> With a space after the first name: and i got an error say : parser error : Specification mandate value for attribute Doh are there anyway to make that work if there will be space in my folder name?
-
its not readying the xml. and there are no error message but it just didn't show anything from my xml
-
I am having issue on my PHP photo gallery. The album name is generate by the folder name as below: '. $_GET['album' So what I am trying to do is to show some external xml date in the gallery base on different albums name, I now tested with 3 different albums with the folder name Adriana, Alicia and Eva. Once again the album name is generate by the folder name. $folder_name = $_GET['album']; echo $folder_name; The above code is working to get the title on specific folder name of that album. Next I have a external xml file with different info for each album. Which I would like to show different info for each album. my xml file as below: <?xml version="1.0" encoding="UTF-8"?> <library> <models> <Adriana>This is the model info of Adriana</Adriana> <Alicia>This is the model info of Alicia</Alicia> <Eva>This is the model info of Eva</Eva> </models> </library> I first tested with this code to make sure it can read the "info": <?php $url = 'albums/Adriana/info.xml'; $xml = simplexml_load_file($url); $info=$xml->models->Adriana; echo $info; ?> Above code works fine, but what I really need to do is something like this, and this is the part that I got an error. $info=$xml->models->$folder_name; Please let me know what am i missing on the above line.
-
Thanks for the reply, with the above code will only show the local date. what I am trying to do is the pull the date from a Tumblr XML API as below. <posts start="1" total="77"> <post id="38470857535" url="http://myblog.tumblr.com/post/38470857535" url-with-slug="http://myblogblog.tumblr.com/post/38470857535" type="photo"date-gmt="2012-12-21 16:38:51 GMT" date="Fri, 21 Dec 2012 11:38:51" unix-timestamp="1356107931" format="html" reblog-key="3ZWYJfgn" slug="" width="1064"> And I used the code below to call it: <?php $request_url = "http://myblog.tumblr.com/api/read?start=0&num=1"; $xml = simplexml_load_file($request_url); $date = $xml->posts->post ['date']; in order to get the posting date I need to "= $xml->posts->post ['date'];" so is there anyway to do something like = $xml->posts->post ['date'("D, d M Y", strtotime($date)];
-
Hi PHP expert, I am trying to read the post date from my tumblr api with the following code. $date = $xml->posts->post ['date']; echo '<p>'.$date.'</p>'; This is what I get from the above code "Wed, 21 Nov 2012 13:32:00" My question is, are there anyways I can get the date with out the hour, min and seconds? for example "Wed,21 Nov 2012"?
-
Just checked with my Hosting company, and they did have url wrappers turned off. So this suggestion by Premiso work, with the following code: $url = "http://jeffhui.tumblr.com/api/read?start=0&num=1"; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $result = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($result); Myself prefer simplexml, so I just called my Hosting company and they did that on there server: allow_url_fopen = On allow_url_include = On Now everything back to normal =) Thank You guys!
-
I am trying to pull XML content from Tumblr into my website. This is the following code that i have problem with: <?php $request_url = "http://jeffhui.tumblr.com/api/read?start=0&num=1"; $xml = simplexml_load_file($request_url); $title = $xml->posts->post->{'regular-title'}; $post = $xml->posts->post->{'regular-body'}; $link = $xml->posts->post['url']; $small_post = substr($post,0,420); echo '<h1>'.$title.'</h1>'; echo '<p>'.$small_post.'</p>'; echo "…"; echo "</br><a target=frame2 href='".$link."'>Read More</a>"; ?> Above code work fine within my internal web server, but when I FTP it to my hosting company it stop working. (My hosting company is CGI-BIN + PHP 4 & 5 Support) Jeff