在facebook中如何用javascript SDK单独请求某一个用户权限

facebook官方javascript SDK文档地址:

http://developers.facebook.com/docs/reference/javascript/

翻来翻去都没看到有单独请求某一个permission的api,

只看到有FB.ui()可以以弹出窗口的形式调用某个graph api,

但找遍graph api,只看到有读取当前用户给当前app开放的permissions,

但没看到有请求单个permission的api。

参考网上大家的做法并测试,

得出如下方法:

FB.ui({

method: ‘permissions.request‘,

perms: ‘publish_stream’,

display: ‘popup

},

function(response) {

//do something

});

上述所传的三个参数为实现该功能的关键

 

Posted in FB Connect | Leave a comment

把facebook帐号登录功能嵌入到你的网页中

参考了developer.facebook.com中的javascript SDK的文档,

官方javascript SDK文档以及sample网址:http://developers.facebook.com/docs/reference/javascript/

并做了一些测试,

发现其文档中的事件监听回调方式并不是能完全符合预期地工作,

在用户从facebook官网登录之后,

然后再到app的页面登录,

此时auth.login、auth.sessionChange、auth.statusChange事件都不能正确地触发,导致app登录失败。

 

参考别的网站的做法,

发现在fb登录按钮的标签上添加了一个onlogin=”"属性,

通过这种方式设置的登录事件监听回调能稳定且正常地工作。

示例代码如下:

<fb:login-button onlogin=”fbLogin()” perms=”email,user_about_me”><a><span>用facebook登入</span></a></fb:login-button>

看来facebook的javascript SDK还需完善才行。

 

Posted in FB Connect | Leave a comment

How to use PuTTY(using SSH tunnel) to break the Wall in windows!

As we know,

lot of good sites can not be accessed in the Great China,

Here is the way to break the fucking wall.

1. Install a proxy server in you linux server, a good proxy server soft is Squid.

Here is the good article about “Install Squid Proxy on CentOS / Redhat enterprise Linux 5“.

Before you start the squid service, you should open it’s config file: ‘vim /etc/squid/squid.conf’,

and search the word “visible_hostname“,

add the tag like this: “visible_hostname {your server’s host name}”

 

2. Use PuTTY to create an SSH tunnel between your pc and your Linux Server.

There is a perfect article about “Using PuTTY under Windows to create an SSH tunnel to your NetManager“.

When you create a PuTTY tunnel, you need to add a tunnel like this:

Source port: 3218

Destination: localhost:3128

Squid use the port “3128″ as default.

 

3. Config your Browser’s proxy server

server: localhost

port: 3128

 

4. Use PuTTY connect to your linux server, and enjoy the free to access any web site in the world!

 

Hurray~

 

Posted in Hack | Leave a comment

swfupload上传多文件uploadSuccess回调事件存在服务器数据传递重复的bug

在使用swfupload最新版做文件上传时,

发现在uploadsuccess事件的回调函数中,

服务器回传到server data存在传递数据错误的bug

例如一次选择三个文件,a.jpg, b.jpg, c.jpg

服务器在文件上传成功后,输出所上传的文件名,

在server data中拿到的三次都是最后一个c.jpg。

 

同时也发现,如果在uploadsuccess回调函数中,

用alert()函数提示server data的时候,

则每次都能获得正确的server data。

 

所以怀疑是swfupload里在处理这个回调函数的时候存在bug

最终解决办法,

由于无法在js中添加让程序等待的一段时间的功能,

所以在php服务器端代码中添加:sleep(1) 让程序暂停一秒

加了暂停代码之后,

uploadsuccess回调函数中都能拿到正确的服务器端数据server data。

 

Posted in F2E | Leave a comment

教你如何禁止百度蜘蛛来爬你的网站或网页

禁止搜索引擎跟踪网页的链接,而只对网页建索引

可以在网页的<head></head>中间添加如下内容:

<meta name=”Baiduspider” content=”nofollow”>

如果想整站禁止百度蜘蛛,

则可在网站根目录下创建文本文件:robots.txt

并添加内容如下:

User-agent: *

Disallow:

 

User-agent: Baiduspider

Disallow: /

 

——-末了——–

尽量自力更生,不依靠百度才是长久之计。。

Posted in F2E | Leave a comment