<??? แจกโค้ด php อย่างง่ายๆ ครับ เอาไปประยุกต์ใช้งานได้ รอบที่ 1 ???>

เริ่มโดย nistelbooy, 03 พฤศจิกายน 2011, 13:49:43

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

nistelbooy

แจกโค้ด php อย่างง่ายๆ ครับ เอาไปประยุกต์ใช้งานได้

1. ดึงสถานะของ twitter ล่าสุด มาแสดง


<?php
$username 
"CNN";
$json file_get_contents("http://twitter.com/statuses/user_timeline/".$username.".json");
$json json_decode($jsontrue);

echo 
"<ul>";
for(
$i=0$i && isset($json[$i]); $i  ) {
 
$text explode("http://",$json[$i]['text']);
 
$msg $text[0];
 
$link = ($text[1] ? "http://".$text[1]:"#");
 
$date date("d/m/Y",strtotime($json[$i]['created_at']));
 if(
$link){
  echo 
"<li>Create $date : <a href="$link" target="_blank">$msg</a></li>";
 }else{
  echo 
"<li>Create $date : $msg</li>";
 }

echo 
"</ul>";
?>




2. ดึงคลิปจาก youtube ด้วย keyword


<?php
function YoutubeKeyword($keyword,$limit=5){
 
$q  $keyword;
 
$q  ereg_replace('[[:space:]] ''/'trim($q));
 
$feedURL "http://gdata.youtube.com/feeds/api/videos/-/{$q}?max-results={$limit}"// orderby=viewCount&
 
$sxml   simplexml_load_file($feedURL);
 
$return  = array();
 foreach (
$sxml->entry as $entry) {
  
$media $entry->children('http://search.yahoo.com/mrss/');
  
$attrs  $media->group->player->attributes();
  
$watch $attrs['url']; 
  
$attrs  $media->group->thumbnail[0]->attributes();
  
$thumbnail $attrs['url']; 
  
$code  explode("?v=",$watch);
  
$code  $code[1];
  
$code  explode("&feature",$code);
  
$code  $code[0];
  
$title  $media->group->title;
  
$desc  $media->group->description;
  
$thumb $thumbnail;
  
$return[] = array(
    
'code'=>$code,
    
'title'=>$title,
    
'desc'=>$desc,
    
'thumb'=>$thumb
    
);
 }
 return 
$return;
}

$keyword "Starcraft Trailer";
$get_youtbe_video YoutubeKeyword($keyword,2);
echo 
'<pre>';
print_r($get_youtbe_video);
echo 
'</pre>';
?>




3. ดึงจำนวน follower twitter


<?php
# top5 : ladygaga, justinbieber, BarackObama, britneyspears, katyperry

$username "ladygaga";
$api_page 'http://twitter.com/users/show/' $username;
$xml file_get_contents $api_page );
$profile = new SimpleXMLElement $xml );
$count $profile->followers_count;
$count number_format($count);

echo 
'Ladygaga : '.$count.' people follow';

?>




4. ดึงจำนวนคนที่กด like facebook page


<?php 
# top 5 : facebook, TexasHoldEm, youtube, eminem, rihanna, ladygaga  
$page_id "rihanna";  

$query "https://graph.facebook.com/$page_id";  
$content file_get_contents($query);  
$decode json_decode($content);  
$count $decode->likes;
$count number_format($count);

echo 
'Rihanna : '.$count.' people like';
?>




5. โค้ดตัวอย่างการสร้างหน้าเนื้อหา แล้วสามารถ share like ไปยัง facebook ได้


<html>
<head>
<meta name="title" content="[title of content-here]" />
<link rel="image_src" href="[image-url-of-content]" />
</head>
<body>
<script src="http://connect.facebook.net/en_US/all.js#appId=226739144021571&amp;xfbml=1"></script>
<div id="fb-root"></div>
<div>
<h1>[title of content]</h1>
<p><img src="[image-url-of-content]" border="0" alt="" /></p>
<p>[this is content]</p>
<p>
<a href="http://www.facebook.com/share.php?t=image-url-of-content&u=[url-of-page]" target="_blank">facebook share (image here)</a>
<iframe src="http://www.facebook.com/plugins/like.php?href=[url-of-page]&amp;layout=button_count&amp;show_faces=false&amp;width=80&amp;action=like&amp;colorscheme=light&amp;height=20" style="width:100px;height:20px;" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
</p>
</div>
</body>
</html>


ถูกใจก็แทงกันไปครับ อิอิ  1
งดรับงาน

บักแฉะ

ทุกข์สมุทัยนิโรธมรรค [direct=http://www.okmyphone.com]อุปกรณ์มือถือ[/direct][direct=http://www.thaiweddinggift.com]ของชําร่วย[/direct][direct=http://youngtoyoungbeauty.blogspot.com/]ครีมยกกระชับ[/direct]

kantz

โอ้  สุดยอด.. เอ ทั้งหมดนี้ มันอยู่ในโค้ดที่ท่านเขียนในเว๊บนี้ครับ
ผมขอเก็บก่อนละกันนะครับ

เมื่อไหร่จะเขียนสคริป(หางาน)แบบจัดเต็มล่ะครับ รอดูผลงานอยู่

http://bit.ly/396Jsiu ---> American America 


ช่อง Youtube - American-America  --> อยากจีบสาวอเมริกา - อยากมีแฟนฝรั่ง -ชีวิตในอเมริกา -ตะลุยอเมริกา - ตามติดที่นี้