แสดงกระทู้
|
หน้า: [1] 2 3 ... 20
|
7
|
พัฒนาเว็บไซต์ / Programming / ตั้งเวลา update ข้อมูล ตามเวลาประจำวันไม่ได้ รบกวนช่วยดู code ให้หน่อยครับ
|
เมื่อ: 29 มิถุนายน 2018, 09:19:12
|
ตั้งเวลา update ข้อมูล ตามเวลาประจำวันไม่ได้ รบกวนช่วยดู code ให้หน่อยครับ $DateResult = date("Y-m-d", mktime(date("h")-01)); $sql = "UPDATE member SET status ='1' WHERE datenow < '$DateResult' "; $query = mysqli_query($objConnect,$sql); ผมตั้งให้มัน update ข้อมูลทุก ๆ 1 ชม. แต่ผลที่ได้ มันไม่อัพเดทให้ภายในวัน วันนั้น แต่วันก่อนหน้า Update เข้าปกติครับ
|
|
|
8
|
พัฒนาเว็บไซต์ / Programming / รบกวนดูโค้ต Js ของ facebook ให้หน่อยครับ
|
เมื่อ: 16 มิถุนายน 2018, 15:13:06
|
อันนี้ใช้ได้ปกติ แต่ผมอยากเพิ่มให้มัน ดึงข้อมูลได้หลาย ID มากขึ้น
privateObj.callFB = function(newConfig){ FB.api("/"+newConfig.pagename, { access_token : newConfig.token, "fields" :"picture{url},name,cover,fan_count,link,posts.limit("+newConfig.feedlimit+"){attachments, likes.limit(0).summary(true), message, created_time, link}" }, function (response) { if (!response.error) { newConfig.onLoad(privateObj.formatResponse[newConfig.format](response, newConfig), newConfig.format, response); } else { newConfig.onLoad(response.error, 'json'); } } ); }; ผมเลยปรับไปเป็น ids ดังนี้ครับ แต่มันไม่ทรายสามารถใช้งานได้ครับ รบกวนพี่ ๆ หน่อยนะครับ
privateObj.callFB = function(newConfig){ FB.api("/",{ access_token : newConfig.token, "ids" : +newConfig.pagename, "fields" :"picture{url},name,cover,fan_count,link,posts.limit("+newConfig.feedlimit+"){attachments, likes.limit(0).summary(true), message, created_time, link}" }, function (response) { if (!response.error) { newConfig.onLoad(privateObj.formatResponse[newConfig.format](response, newConfig), newConfig.format, response); } else { newConfig.onLoad(response.error, 'json'); } } ); };
|
|
|
9
|
พัฒนาเว็บไซต์ / Programming / Re: จะเอา Feed ของ page ต่างๆ มาติดไว้ในเว็บของเราอย่างไรดีครับ php
|
เมื่อ: 15 มิถุนายน 2018, 13:50:07
|
ตอนนี้ดึงได้แล้วครับ สอบถามเพิ่มเติมครับ ถ้าจะดึงจาก หลาย ๆ Page มารวมในหน้าเว็บของเรา ให้มีข้อมูลมากกว่า 1 Page แบบ All รวม ๆ ต้องทำอย่างไรดีครับ ช่วยแนะนำหน่อยครับ เพราะตอนนี้ทำได้แค่ดึงเพจเดียว ขอบคุณครับ <script type="text/javascript"> //initialize and set defaults var fbFeed = new FacebookPageFeed({ 'appid' : 'YOUR_APPID', 'token' : 'YOUR_APP_TOKEN', 'pagename' : 'bnk48official.noey', 'feedlimit' : 100, 'format' : 'html', //json, 'dateFormat': function(date){ return date; //format date string with moment.js or others... }, 'likesFormat': function(likes){ return likes; //format likes number... }, 'template' : function(page, post){ //console.log(page, post); var tpl = '<h1>' page.name '</h1>'; tpl = '<p>' post.message '</p>'; return tpl; }, onLoad: function(res){ console.log(res); //the result } });
|
|
|
11
|
พัฒนาเว็บไซต์ / Programming / Facebook Open Graph API เรียก Feed ไม่มา ช่วยด้วยครับ
|
เมื่อ: 14 มิถุนายน 2018, 17:17:23
|
โค้ดผมดูมาจากเว็บนี้ครับ http://www.daydev.com/develope...age/facebook-open-graph-7.html  ลองเอามาปรับใช้ดูมันก็ ERROR เลยครับ ผมต้องเปลี่ยนแปลงตรงไหนหรือเปล่าครับ ขอบคุณครับ <?php
require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'APP ID', 'secret' => 'APP SECRET', )); $scope='email,publish_actions,publish_stream,user_likes,user_photos,user_relationships,user_relationship_details,read_stream'; // Get User ID $user = $facebook->getUser(); $access_token = $facebook->getAccessToken();
if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } }
// Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(array( 'scope' => $scope, )); }
// This call will always work since we are fetching public data. $daydev = $facebook->api('/daydevthailand');
?> <!DOCTYPE> <html xmlns:fb="http://ogp.me/ns/fb#"> <head> <title>Facebook Open Graph API Examples by @daydev</title> <meta charset="utf-8"> <link type="text/css" rel="stylesheet" href="styles/style.css" /> <!--[if IE 6]> <script src="js/ie6-transparency.js"></script> <script>DD_belatedPNG.fix('#wrap .line, #header #header-photo');</script> <link rel="stylesheet" href="styles/ie6.css" /> <![endif]--> <!--[if IE 7]><link rel="stylesheet" href="styles/ie7.css" /><![endif]--> <!--[if IE 8]><link rel="stylesheet" href="styles/ie8.css" /><![endif]--> <!--[if IE 9]><link rel="stylesheet" href="styles/ie9.css" /><![endif]--> </head> <body> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=406833949401207"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <script src="//connect.facebook.net/en_US/all.js"></script> <div id="wrap"> <div id="header"> <?php if ($user) {?> <div id="header-content"> <h2><a href="<?php echo $logoutUrl; ?>">Logout</a></h2> <h1><?=$user_profile['name'];?></h1> <h2>Profiles:</h2> <p><?=$user_profile['bio']?></p> <div id="contact-details"> <p class="contact"><span>Email: </span><?=$user_profile['email'];?></p> <p class="contact"><span>Religion: </span><?=$user_profile['religion'];?></p> <p class="contact"><span>Relation: </span><a href="http://www.facebook.com/<?=$user_profile['significant_other']['id'];?>"><?=$user_profile['significant_other']['name'];?></a></p> </div> </div> <!--end header-content--> <div id="header-photo" style="background-image:url(http://graph.facebook.com/<?=$user_profile["id"];?>/picture?type=large); background-repeat:no-repeat; width:170px; height:220px;"> </div> <!--end header-photo--> </div> <!--end header-->
<?php }else{ ?>
<div id="header-content"> <a href="<?php echo $loginUrl; ?>"> <img src="images/facebook-connect-button.png" style="padding-bottom:20px;"/> </a> <h1>Please Login with Facebook</h1> <h2>Your data will display</h2> <p>Powered by <a href="http://twitter.com/daydev">@daydev</a> [Banyapon Poolsawasd] and Free-Css for Website Template</p> <div id="contact-details"> <p class="contact"><span>Email: </span>[email protected]</p> <p class="contact"><span>Website: </span>[url=http://www.daydev.com]www.daydev.com[/url]</p> </div> </div> <!--end header-content--> <div id="header-photo" style="background-image:url(images/placeholder.png); background-repeat:no-repeat;"><img src="images/placeholder.png"/> </div> <!--end header-photo--> </div> <!--end header--> <?php } ?> <div align="center"> <script type="text/javascript"><!-- google_ad_client = "ca-pub-5951866056770179"; /* LeaderBoard */ google_ad_slot = "7899721000"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <div class="line"></div> <div id="content"> <div id="experience" class="cv-section"> <h3>Experience</h3> <?php $source='[url]https://graph.facebook.com/'.[/url]$user_profile["id"].'?fields=feed&access_token='.$access_token.'&limit=30'; $jsource=file_get_contents($source); $jsonfeed = json_decode($jsource);
foreach ($jsonfeed->feed->data as $data ) { ?> <div class="cv-section-item"> <h4 class="title"><?php echo $data->from->name;?></h4> <?php if(empty($data->message)){?> <h4 class="meta"> </h4> <?php }else{?> <h4 class="meta">"<?php echo $data->message;?>"</h4> <?php }?> <img src="http://graph.facebook.com/<?php echo $data->from->id;?>/picture" style=" border:#006699 solid 5px;" align="left"/> <?php if(empty($data->picture)){}else{?> <img src="<?php echo $data->picture;?>" style="width:80px; margin-bottom:10px; border:#999999 solid 5px;" align="right"/> <?php }?> <div style="margin-left:65px; width:540px;"><p><?php echo date("d (D), M Y", strtotime($data->created_time));?></p> <?php if(empty($data->name)){?> <p>Shared some content! <a href="http://www.daydev.com" title="Social Media Marketing">Social Media Marketing</a></p> <?php }else{ ?> <p><a href="<?php echo $data->link;?>">"<?php echo $data->name;?>"</a></p> <p><?php echo $data->description;?></p> <?php }?> <?php if(empty($data->application->name)){}else{?> <?php }?> <p> <?php foreach($data->likes->data as $valike){?> <a href="http://www.facebook.com/<?php echo $valike->id;?>"><img src="http://graph.facebook.com/<?php echo $valike->id;?>/picture" style="float:left; padding-right:5px; width:24px; height:24px;"/></a> <?php }?> <?php if(empty($data->likes->count)){}else{?>Likes: ( <?php echo $data->likes->count;?> )<?php }?></p> </div> <div class="line"></div> <?php foreach($data->comments->data as $values){ ?> <div style="margin-left:65px; width:540px; padding-left:5px; background-color:#EBEBEB; border:#999999 solid 1px; margin-top:15px; vertical-align:text-top;"> <a href="http://www.facebook.com/<?php echo $values->from->id;?>"><img src="http://graph.facebook.com/<?php echo $values->from->id;?>/picture" style="margin-right:10px; margin-top:5px; border:#999999 solid 5px;" align="right"/></a> <h4>Comments by <a href="http://www.facebook.com/<?php echo $com_name=$values->from->id;?>"><?php echo $com_name=$values->from->name;?></a></h4> <p><?php echo $com_message=$values->message;?></p> </div> <?php }?> </div> <!--end cv-section-item--> <?php } ?> </div> <!--end experience--> <!--end education--> <div class="line"></div> <!--end training--> </div> <!--end content--> </div> <!--end wrap--> <div id="spacing"></div> <!--hack for ie6 and ie7-->
</body> </html>
|
|
|
20
|
พัฒนาเว็บไซต์ / Programming / จะทำ login line ในเว็บไซต์ แต่ดึงค่าไม่มา ช่วยดูโค้ตให้ทีครับ
|
เมื่อ: 21 พฤษภาคม 2018, 17:38:51
|
พอเชื่อมต่อ login line เข้ามาได้ แต่ไม่ได้ข้อมูลของ user มาด้วยเลยครับ ลอง echo ไม่ออกสักค่าเลย รบกวนด้วยครับ ขอบคุณครับ <? session_start(); $client_id = "xxx"; $client_secret = "xxx"; $redirect_uri = "http://xxx/line/check.php"; $token = "";
function getToken($code){ global $client_id, $client_secret,$redirect_uri;
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => "https://api.line.me/v2/oauth/accessToken", CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=".$code."&client_id=".$client_id."&client_secret=".$client_secret."&redirect_uri=".$redirect_uri, CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/x-www-form-urlencoded" ), ));
$response = curl_exec($curl); curl_close($curl);
return $response; }
function getProfile(){ global $token;
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => "https://api.line.me/v2/profile", CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer ".$token, "cache-control: no-cache" ), ));
$response = curl_exec($curl); curl_close($curl);
return $response; }
$obj = json_decode(getToken($_GET['code']),true); $token = $obj['access_token']; $obj_profile = json_decode(getProfile(),true); /*print_r($obj); print_r($obj_profile)*/ /*echo $token ; echo $obj_profile['displayName'] ; echo $obj_profile['mid']; echo $obj_profile['pictureUrl']; echo $obj_profile['statusMessage'] ;*/
$dp = $obj_profile['displayName']; $pg = $obj_profile['pictureUrl']; $ipaddress = $_SERVER['REMOTE_ADDR']; //Get user IP ?>
|
|
|
|
|