Rabu, 19 Oktober 2011

cara mudah membuat halaman auto generate content (AGC)


cara mudah membuat halaman auto generate content (AGC),oke langsung saja,sebenarnya saya gak pandai bikin tutorial apalagi utak atik script php,html aja masih mumet :) ini tutorial saya ringkas saja dari beberapa tutorial yang saya temukan di beberapa tempat
cara membuat AGC
step 1.
dapatkan Bing Search API lebih dulu di sini http://www.bing.com/developers/createapp.aspx (gak perlu tutorialkan untuk mendapatkan api dari bing  )
step 2.
Buka editor search.php template kamu kemudian hapus kode
kemudian ganti dengan kode berikut ini

?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if($_GET['s']!=''){
$urlredirect = get_settings('home') . '/search/' . str_replace(' ', '-' ,$_GET['s']). '.html';
header("HTTP/1.1 301 Moved Permanently");
header( "Location: $urlredirect" );
}
?>
define('BING_API_KEY', '');
function pete_curl_get($url, $params)
{
$post_params = array();
foreach ($params as $key => &$val) {
if (is_array($val)) $val = implode(',', $val);
$post_params[] = $key.'='.urlencode($val);
}
$post_string = implode('&', $post_params);
$fullurl = $url."?".$post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_URL, $fullurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mailana (curl)');
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function perform_bing_web_search($termstring)
{
$searchurl = 'http://api.bing.net/json.aspx?';
$searchurl .= 'AppId='.'ganti dengan kode api kamu dari bing';
$searchurl .= '&Query='.urlencode($termstring);
$searchurl .= '&Sources=Web';
$searchurl .= '&Web.Count=10';
$searchurl .= '&Web.Offset=0';
$searchurl .= '&Web.Options=DisableHostCollapsing+DisableQueryAlterations';
$searchurl .= '&JsonType=raw';
$response = pete_curl_get($searchurl, array());
$responseobject = json_decode($response, true);
if ($responseobject['SearchResponse']['Web']['Total']==0)
return array();
$allresponseresults = $responseobject['SearchResponse']['Web']['Results'];
$result = array();
foreach ($allresponseresults as $responseresult)
{
$result[] = array(
'url' => $responseresult['Url'],
'title' => $responseresult['Title'],
'abstract' => $responseresult['Description'],
);
}
return $result;
}
if (isset($_REQUEST['s'])) {
$termstring = urldecode($_REQUEST['s']);
} else {
$termstring = '';
}
get_header(); ?>


kemudian cari kode  dan pasang kode berikut ini di atasnya


?Download download.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// If this is a search
if (is_search()) {
$s = str_replace('-', ' ', $s);
echo '

'; echo 'Search Result for: '.$s.''; echo '

'; // If this is a category archive } ?> function CleanFileNameBan($result){ $bannedkey = array("porn","adult","sex"); //masukkan kata kunci satu persatu untuk menghindari kata-kata yang tidak diinginkan. $result = str_replace($bannedkey, '',$result); $result = trim($result); return $result; } function hilangkan_spesial_karakter($result) { //fungsi hilangkan semua spesial karakter pada Title $result = strip_tags($result); $result = preg_replace('/&.+?;/', '', $result); $result = preg_replace('/\s+/', ' ', $result); $result = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', ' ', $result); $result = preg_replace('|-+|', ' ', $result); $result = preg_replace('/&#?[a-z0-9]+;/i','',$result); $result = preg_replace('/[^%A-Za-z0-9 _-]/', ' ', $result); $result = trim($result, ' '); return $result; } function ubah_tanda($result) { //fungsi ubah spasi jadi minus pada permalink title $result = strtolower($result); $result = preg_replace('/&.+?;/', '', $result); $result = preg_replace('/\s+/', '-', $result); $result = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '-', $result); $result = preg_replace('|-+|', '-', $result); $result = preg_replace('/&#?[a-z0-9]+;/i','',$result); $result = preg_replace('/[^%A-Za-z0-9 _-]/', '-', $result); $result = trim($result, '-'); return $result; } ?> if ($termstring!='') { $bingresults = perform_bing_web_search($termstring); foreach ($bingresults as $result) { print '

'.CleanFileNameBan(hilangkan_spesial_karakter($result['title'])).'

'; print ''.$result['abstract'].' '; print ''.$result['url'].'
'; } } ?>
simpan dan test hasilnya

Related Articles :


Stumble
Delicious
Technorati
Twitter
Facebook

0 komentar:

Posting Komentar

ATTENTION !
BLOG INI 100% DOFOLLOW !

 

FalconBoy Copyright © 2010 LKart Theme is Designed by Lasantha