http://www.sslshopper.com/article-how-to-configure-ssl-host-headers-in-iis-6.html
//方法一 FQL
FB.api({
method: ‘fql.query’,
query: ‘SELECT uid FROM page_fan WHERE uid=’ + fb_uid + ‘ AND page_id=’ + page_id
}, function (resp) {
if (resp.length) {
//is fans
} else {
//not fans
}
});
//方法二 isFan Method
FB.api({
method: ‘pages.isFan’,
page_id: page_id,
uid: fb_uid
}, function (resp) {
if (resp == true) {
//is fans
} else if (resp.error_code) {
alert(resp.error_msg);
} else {
//not fans
}
});
//方法三
FB.api("/me/likes/" + page_id, function (res) {
if (res.data) {
if (isEmpty(res.data)) {
//not fans
} else {
//is fans
}
} else {
alert("check error");
}
});
function isEmpty(obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) return false;
}
return true;
}
FB.Data.waitOn([commentQuery, userQuery], function () {
var commentRow = commentQuery.value[0];
var userRow = userQuery.value[0];
var commentText = commentRow.text;
var commentUsername = userRow.name;
alert(commentText);
});
});
};
(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_US/all.js#xfbml=1&appId=xxxxxxxx";
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));
</script>
<fb:comments href="http://domain.com" num_posts="2" width="470" notify="true" migrated="1"></fb:comments>
</body>
</html>
$facebook = new Facebook(array(
‘appId’ => ‘xxxxx’,
‘secret’ => ‘xxxxxxxx’,
‘cookie’ => true,
‘fileUpload’ => true
));
// Get User ID
$user = $facebook->getUser();
$file = "1.jpg";
$event_info = array(
"privacy_type" => "SECRET",
"name" => "用api建立活動",
"description" => "php api建立活動",
"category" => 1,
"subcategory" => 1,
"host" => "Me",
"location" => "Taipei",
"city" => "Taipei, Taiwan", //Must be a valid city
"start_time" => gmmktime(0,0,0,3,20,2012),
"end_time" => gmmktime(0,0,0,3,21,2012),
"@file.jpg" => ‘@’.realpath($file)
);
try{
$event_result = $facebook->api(‘me/events’,‘post’,$event_info);
echo ‘Event Created! Event Id is: ‘.$event_result["id"];
$ids = array("1000000001111");
$facebook->api(array(
‘method’ => ‘events.invite’,
‘eid’ => $event_result["id"],
‘uids’ => $ids,
‘personal_message’ => "invite you",
));
}
catch(Exception $e){
echo ‘Error message: ‘.$e->getMessage().‘ Error code:’.$e->getCode();
}
?>
之前做的 POPO網 那邊有一個標籤的功能
但是標籤對應照片的總和我一直沒處理
原因也是因為我不想在程式端裡面做TAG COUNT的運算(至少目前為止我不想)
所以就將他拉到排程來做
MSSQL就更簡單了, 只要寫好stored procedure然後丟到jobs去就完工
Mysql的話, 先啟用 MYSQL排程 的功能
SET GLOBAL event_scheduler = ON;
SET @@global.event_scheduler = ON;
SET GLOBAL event_scheduler = 1;
SET @@global.event_scheduler = 1;
這邊我遇到了一個 Error 1577 "Cannot proceed because system table used by Event Scheduler were found damaged at server start" 的錯誤
不曉得是XAMPP的mysql設定問題還是我當初做 DB 轉移的時候造成之後的毀損
總之後來透過 mysql_upgrade -u root -p 的command來解決
接著再參考mysql 5.1的文件設定
CREATE EVENT popo_tagcount_update
ON SCHEDULE
EVERY 3 HOUR
DO
update tags set tags.tag_count = (select count(record_id) as cnt from photos_tags where photos_tags.tag_id=tags.tag_id)
這樣就加上了一筆排程
接著來看一下排程 SHOW EVENTS
會看到一筆剛剛建立的 SCHEDULE, 就完成了
如果之後要修改時間長度的話可以用
ALTER EVENT popo_tagcount_update
ON SCHEDULE
EVERY 1 HOUR
使用版本 5.4.1
http://www.facebook.com/csharpsdk
http://docs.csharpsdk.org/
using System;
using System.Web;
using System.Linq;
using System.Collections;
using System.Dynamic;
using System.IO;
public class fb_handle : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string fb_token = "token";
string fb_album_name = "My Album";
var fb = new Facebook.FacebookClient(fb_token);
string fb_album_id;
dynamic album = fb.Query("SELECT aid, owner, name, object_id FROM album WHERE owner=me() and name=\"" + fb_album_name + "\" AND can_upload=1");
if (album.Count == 0)
{
//create album
dynamic albumDetails = new ExpandoObject();
albumDetails.name = fb_album_name;
dynamic fbResult = fb.Post("/me/albums", albumDetails);
fb_album_id = fbResult.id;
}
else
{
fb_album_id = album[0].object_id.ToString();
}
dynamic parameters = new ExpandoObject();
parameters.message = "Hello World!";
parameters.image = new Facebook.FacebookMediaObject { ContentType = "image/jpeg", FileName = "upload.jpg" }.SetValue(File.ReadAllBytes(context.Server.MapPath("../upload/") + "1d5698ce-7b27-42ba-b8b5-6cbb50aff164_after.jpg"));
dynamic result = fb.Post("/" + fb_album_id + "/photos", parameters);
var id = result.id;
context.Response.Write(id);
}
public bool IsReusable {
get {
return false;
}
}
}
$user = $facebook->getUser();
if ($user) {
try {
echo "get friend<br>";
$all_friends_profile = $facebook->api(array(
‘method’=>‘fql.query’,
‘req_perms’ => ‘friends_birthday’,
‘query’=>"select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())")
);
//var_dump($all_friends_profile);
foreach($all_friends_profile as $profile){
echo $profile["name"]." birthay=".$profile["birthday_date"]." Horoscope=".GetHoroscope($profile["birthday_date"])."<br>";
}
} catch (FacebookApiException $e) {
echo $e;
}
$logoutUrl = $facebook->getLogoutUrl();
echo "<a href=\"$logoutUrl\">Logout</a>";
}else{
echo "not fb user";
$scope = "email,friends_birthday,read_stream,share_item,publish_stream,offline_access";
$loginUrl = $facebook->getLoginUrl(array(‘scope’ => $scope));
echo "<a href=\"$loginUrl\">Login with Facebook</a>";
}
function GetHoroscope($birth){
$arybirth = preg_split(‘/[- :]/’,$birth);
$nX = $arybirth[0] * 100 + $arybirth[1];
if ( $nX >= 321 && $nX <= 419 ){
return "牡羊";
}else if ( $nX >= 420 && $nX <= 520 ){
return "金牛";
}else if ( $nX >= 521 && $nX <= 621 ){
return "雙子";
}else if ( $nX >= 622 && $nX <= 722 ){
return "巨蟹";
}else if ( $nX >= 723 && $nX <= 822 ){
return "獅子";
}else if ( $nX >= 823 && $nX <= 922 ){
return "處女";
}else if ( $nX >= 923 && $nX <= 1023 ){
return "天秤";
}else if ( $nX >= 1024 && $nX <= 1122 ){
return "天蠍";
}else if ( $nX >= 1123 && $nX <= 1221 ){
return "射手";
}else if ( $nX >= 1222 || $nX <= 119 ){
return "摩羯";
}else if ( $nX >= 120 && $nX <= 218 ){
return "水瓶";
}else if ( $nX >= 219 && $nX <= 320 ){
return "雙魚";
}else{
return "";
}
}
?>
</body>
</html>
foreach ($likeuser as $user){
echo "<img src=\"https://graph.facebook.com/".$user["uid"]."/picture?type=square\">".$user["like"]."<br>";
}
要在apache裡面設定這些mime-type對應
否則影片播放會異常
public partial class token : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string url = "https://graph.facebook.com/me?access_token=xxxxxxxxxxxxxxxxxxxxxxx";
JObject myProfile = JObject.Parse(requestFBData(url));
string myID = myProfile["id"].ToString().Replace("\"", "");
string myName = myProfile["name"].ToString().Replace("\"", "");
string email = myProfile["email"].ToString().Replace("\"", "");
}
public string requestFBData(string action)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(action);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string results = sr.ReadToEnd();
sr.Close();
return results;
}
}