小编pod*_*dek的帖子

Facebook应用程序:服务器端访问令牌验证

简单的facebook应用程序与数据库服务器通信(使用包装器).出于安全原因,需要检查询问服务器某些操作的用户是否真的是他的id的所有者(在请求中发送).

为此,对服务器的请求包含来自基于javascript SDK的Web应用程序的access_token和user的id.我想检查访问令牌的所有者的ID和用户的ID是否相同.第一步是从Facebook获取访问令牌的所有者的ID.使用代码:

class SessionValidator {
    private $userId;            //id of user
    private $accessToken;       //facebook user's access token
    private $fb;
    public function __construct($userId, $accessToken){
        $this->userId = $userId;
        $this->accessToken = $accessToken;
        $app_id = @appId; 
        $app_secret = @secret;

        $fb = new Facebook(array('appId' => $app_id, 'secret' => $app_secret));
        $fb->setAccessToken($accessToken);

        $this->fb = $fb;
    }
    public function authUserSession(){
        $url = 'https://graph.facebook.com/';
        $data['fields'] = $this->userId;
        $data['access_token'] = $this->accessToken;

        $response = $this->post_request($url, $data);

        return $response;
    }
    private function post_request($url, $data){
        return $this->fb->api('/me', 'POST', $data);
    }
}
Run Code Online (Sandbox Code Playgroud)

Facebook一直在回应:

未捕获的OAuthException:(#10)应用程序没有此操作的权限 …

php authentication facebook

3
推荐指数
1
解决办法
3854
查看次数

从集合中删除项目调用java.util.ConcurrentModificationException

我试图从两个排序列表创建排名.

 List<Ordered<String>> rankedList = Collections.synchronizedList(WebCBIR.run(queryData, clusters, idf));
 List<Ordered<String>> rankedList2 = Collections.synchronizedList(WebCBIR.run(queryData, clusters));
 LinkedList<Ordered<String>> result = new LinkedList<>();
 Iterator<Ordered<String>> it = rankedList.iterator();
 Iterator<Ordered<String>> it2 = rankedList2.iterator();

 while (it.hasNext() && it2.hasNext())  {

        Ordered<String> o1 = it.next();
        Ordered<String> o2 = it2.next();
        Ordered<String> o = null;
        if(o1.value() > o2.value()){
            o = o1;
            rankedList.remove(o);
            rankedList2.remove(o);
        }
        else{
            o = o2;
            rankedList.remove(o);
            rankedList2.remove(o);

        }
        result.add(o);
}
Run Code Online (Sandbox Code Playgroud)

此代码调用java.util.ConcurrentModificationException.怎么处理呢?

java collections loops exception

-2
推荐指数
1
解决办法
100
查看次数

标签 统计

authentication ×1

collections ×1

exception ×1

facebook ×1

java ×1

loops ×1

php ×1