Storing facebook token for offline access

前端 未结 3 989
礼貌的吻别
礼貌的吻别 2021-01-03 16:54

I am looking for a way to save the access token to allow the user to post on facebook without having to log in for each call to the graph API :

I require an offline_

3条回答
  •  春和景丽
    2021-01-03 17:23

    Ok it seems that it's the facebook iOS SDK which is buggy.

    Using the token stored in the user defaults, i can perform a post on my wall using curl :

    curl -F 'access_token=br69pK_lh0Xbj....plDRUdG97a55KIHzlaiw' \
         -F 'message=TEST API.' \
         https://graph.facebook.com/ME/feed
    

    So i just perform a HTTPS POST, so using ASIHTTPRequest this code works like a charm :

    NSURL* faceboobUrl = [NSURL URLWithString:@"https://graph.facebook.com/ME/feed"];
    self.request = [ASIFormDataRequest requestWithURL:faceboobUrl];
    [request setRequestMethod:@"POST"];
    [request setPostValue:token forKey:@"access_token"];
    [request setPostValue:msg forKey:@"message"];
    [request setDelegate:self];
    [request setTimeOutSeconds:TIMEOUT];
    [request startAsynchronous];
    

    No thanks facebook ;)

    Vincent

提交回复
热议问题