Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PHP] buat RSS mu sendiri yuk
#1
udah lama gk buat thread Cheer, hari ini ane mau ngeshare cata buat RSS xml sendiri menggunakan PHP Perimaho

langsung aja ke point pentingnya wakaka

pertama, buat percobaan kita pake aja localhost, buat yg blm punya bisa install XAMPP dulu Perimaho comot disini http://www.apachefriends.org/en/xampp.html
( download sesuai OS ya wakaka )
cara installnya banyak di google Bahagia

step 1, buka notepad atau pake text editor kesukaan kalian Cheer
step 2, copy + paste text dibawah
PHP Code:
<?php $db_host = "localhost"; //database host $db_username = "root"; //default XAMPP database username $db_pass = ""; //default XAMPP database password :) $db_name = "test"; //sesuaikan dengan database name kalian mysql_connect("$db_host","$db_username","$db_pass") or die ("nggak bisa connect pakde T.T"); //cantconnect mysql_select_db("$db_name") or die ("Databasenya yang mana pakde T.T"); //unknow database or non-exist database ?>
save ke folder htdocs xampp default windows (C://xampp/htdocs/) atau linux (/opt/lampp/htdocs/)
dengan nama config.php
step 3, copy + paste text dibawah
PHP Code:
<?php header("Content-type: application/xml"); // pasti udah tau donk fungsinya ^_^ include ("config.php"); // ngundang file config.php yang berisi isi config kaya database dan lain2 :D $query = "SELECT * FROM post ORDER BY id DESC"; //query yang bakal dijalanin di SQL ^_^ $result = mysql_query($query); // eksekusi query yang diatas, LoL echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\">\n <channel> <generator>RSS/1.0</generator> <title>Belajar Bareng KillerByte</title><!-- ganti dengan title web/blog agan2 :D --> <description>Pinter itu relatif tau :D</description><!-- ubah dengan description web/blog --> <link>http://haadiy.us/</link><!-- ubah dengan link web/blog agan2 :D --> <language>id</language><!-- ubah dengan bahasa web/blog agan2 :D --> <copyright>(c) 2012 R. Haadiy</copyright>\n";//ubah dengan copyright web/blog agan2 :p while($b = mysql_fetch_array($result)){ echo "<item><title>$b[1]</title> <link>http://website.com/post.php?p=$b[0]</link>//ubah dengan link web agan :D <pubDate>$b[3]</pubDate> <description>$b[2]</description> </item>\n"; } echo "</channel>\n</rss>"; ?>
save dengan nama rss.php
selesai dengan phpnya, sekarang kita lanjut kedatabasenya :D

step 4, buka http://localhost/phpmyadmin/
create database 'test'
trus klik SQL, masukan text dibawah, lalu klik Go
Quote:CREATE TABLE IF NOT EXISTS `post`
(
`id` int(25) NOT NULL AUTO_INCREMENT,

`title` text NOT NULL,

`content` text NOT NULL,

`date` date NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB;


INSERT INTO `post`
(`id`, `title`, `content`, `date`) VALUES

(1, 'title post 1 :p', 'content post 1 :p', '2012-02-15'),

(2, 'title post 2 :p', 'content post 2 :p', '2012-02-15'),

(3, 'title post 3 :p', 'content post 3 :p', '2012-02-15'),

(4, 'title post 4 :p', 'content post 4 :p', '2012-02-15'),

(5, 'title post 5 :p', 'content post 5 :p', '2012-02-16'),

(6, 'title post 6 :p', 'content post 6 :p', '2012-02-16');

step 5, we are done wakaka tinggal di cek di http://localhost/rss.php

cukup sekian thread ane hari ini Piktor kalo masih ada yang kurang jelas, bisa ditanya langsung disini Ganteng
[Image: siggi.gif]
Reply
#2
aktifin xamp dulu ah, biar bisa kaya gitu Ganteng
Reply
#3
Mantab Mantab
keren bro... Bigsmile
bisa jelasin tentang tag2 XML gk??
aku masih bingung tntang XML.. Bingung
My Mind
Reply
#4
Quote:Required channel elements



Title
Name of the RSS channel. For example, it can be the same as the website title.

Description.
Short description of the RSS channel.

Link
Link to the website the channel is related to.



Optional channel elements



Language
The language the channel is written in.

Copyright
RSS channel copyright information.

managingEditor
Email-address of the person responsible for the channel content.

webMaster
Email-address of the person responsible for channel publishing.

pubDate
Date of publishing according to the Date and Time Specification.

lastBuildDate
The last time the content of the channel changed.

Category
Specify one or more categories that the channel belongs to.

Generator
Title of the program used to generate the RSS feed.

Docs
Link to the RSS specification, used for creating the channel.

Ttl
Ttl means ‘time to live’ and specifies channel validity in minutes.

Image
Specify the image file (GIF, JPEG or PNG), which will be displayed in the RSS channel. The following parameters are accepted:

Title
This is usually the same text as RSS Title.

Description
Description of the image file, which will be displayed if the file is unavailable.

Link
Link to the page the channel is related to.

URL
URL of the JPEG, GIF or PNG file, which is linked to the RSS channel.

Width
Image width.

Height
Image height.

skipHours
The period during which RSS readers cannot check the channel for updates, in hours.

skipDays
The period during which RSS readers cannot check the channel for updates, in days.



Required item elements



Title
Item name of the RSS channel.

Description
Short description of the item.

Link
Link to the webpage containing the full description of the event.



Optional item elements



Author
Email-address of the message author.

Category
Item category.

Comments
Link to the webpage containing comments on the item.

Enclosure
This describes the media-object connected to the Item. The following parameters are supported:

URL
Link to the object file

Length
Size of the file in bytes.

Type
File type according to the MIME specification.

Guid
Unique string used to identify the item.

pubDate
Item date of publishing
[Image: siggi.gif]
Reply
#5
yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D

(biar jadi 40 gitu aja lah)
[Image: AaEzha.2.gif]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Ask : add ons buat pasang script adsense ke browser lugiyatna 3 49 02-28-2014, 05:01 AM
Last Post: lugiyatna
  [php+sql]Membuat hash cracking sendiri RieqyNS13 4 161 01-24-2013, 12:18 PM
Last Post: Jheny
  [ask] Cara Buat Web Toko Online aandoni 10 198 07-09-2012, 07:27 AM
Last Post: aandoni
  Buat Autobacklink dengan PHP MySQL tolonggalo 3 136 06-24-2012, 04:06 AM
Last Post: tolonggalo
  [ASK]Cara buat kayak gini thronez.thru 4 212 06-14-2012, 02:37 AM
Last Post: Orphan Walker
  Script buat klasmen bola t4rno 12 231 02-14-2012, 03:23 PM
Last Post: t4rno
  Ada Yang Bisa Buat Seperti Ini Gak ??? ecookies 24 482 02-05-2012, 02:55 PM
Last Post: ecookies
Sarge_16 Cara : Buat Login Administrator 3 Lapis captain_force 25 736 01-20-2012, 05:04 PM
Last Post: E1nzte1N
  Buat HTML Entities tolonggalo 9 163 01-12-2012, 12:53 AM
Last Post: tolonggalo
  {ASK} cara buat template web lewat PHP uzumady 10 220 11-17-2011, 04:54 PM
Last Post: d0ey_Grunch

Forum Jump:


Users browsing this thread: 1 Guest(s)