VKHS 0.5.5 → 0.5.6
raw patch · 3 files changed
+15/−15 lines, 3 files
Files
- VKHS.cabal +1/−1
- src/Web/VKHS/API/Aeson.hs +3/−3
- src/Web/VKHS/Login.hs +11/−11
VKHS.cabal view
@@ -1,6 +1,6 @@ name: VKHS-version: 0.5.5+version: 0.5.6 synopsis: Provides access to Vkontakte social network via public API description: Provides access to Vkontakte API methods. Library requires no interaction
src/Web/VKHS/API/Aeson.hs view
@@ -14,7 +14,7 @@ import Data.Aeson as A import Data.Aeson.Types as A-import Data.Aeson.Generic as AG+import Data.Aeson.Parser as AG import Data.ByteString.Lazy as BS import Data.Data import Data.Vector as V (head, tail)@@ -38,9 +38,9 @@ return (Response x) parseJSON o = parseJSON_obj_error "Response" o -parseGeneric :: (Data a) => A.Value -> A.Parser a+parseGeneric :: (FromJSON a,Data a) => A.Value -> A.Parser a parseGeneric val =- case AG.fromJSON val of+ case A.fromJSON val of A.Success a -> return a A.Error s -> fail $ "parseGeneric fails:" ++ s
src/Web/VKHS/Login.hs view
@@ -42,7 +42,7 @@ import Web.VKHS.Types import Web.VKHS.Curl as VKHS --- Test applications: +-- Test applications: -- -- pirocheck -- ID 3115622@@ -61,8 +61,8 @@ toarg :: [AccessRight] -> String toarg = intercalate "," . map (map toLower . show) --- | Gathers login information into Env data set. -env :: String +-- | Gathers login information into Env data set.+env :: String -- ^ Client ID (provided by VKontakte, also known as application ID) -> String -- ^ User email, able to authenticate the user@@ -71,7 +71,7 @@ -> [AccessRight] -- ^ Access rights to request -> Env LoginEnv-env cid email pwd ar = mkEnv +env cid email pwd ar = mkEnv (LoginEnv [ ("email",email) , ("pass",pwd) ] ar@@ -80,11 +80,11 @@ vk_start_action :: ClientId -> [AccessRight] -> ActionHist vk_start_action cid ac = AH [] $ OpenUrl start_url mempty where- start_url = (\f -> f $ toUri "http://oauth.vk.com/authorize") + start_url = (\f -> f $ toUri "https://oauth.vk.com/authorize") $ set query $ bw params [ ("client_id", cid) , ("scope", toarg ac)- , ("redirect_uri", "http://oauth.vk.com/blank.html")+ , ("redirect_uri", "https://oauth.vk.com/blank.html") , ("display", "wap") , ("response_type", "token") ]@@ -156,7 +156,7 @@ tell [CURLOPT_POST True] tell [CURLOPT_COPYPOSTFIELDS p'] liftVK (return $ parseResponse $ VKHS.unpack s)- + -- | Splits parameters into 3 categories: -- 1)without a value, 2)filled from user dictionary, 3)with default values split_inputs :: [(String,String)]@@ -218,8 +218,8 @@ a = uri_fragment h vk_dump_page :: Int -> Uri -> Page -> IO ()-vk_dump_page n u (h,b) - | (>0) . length . filter (isAlpha) $ b = +vk_dump_page n u (h,b)+ | (>0) . length . filter (isAlpha) $ b = let name = printf "%02d-%s.html" n (showAuthority (get authority u)) in bracket (openFile name WriteMode) (hClose) $ \f -> do hPutStrLn f b@@ -228,8 +228,8 @@ -- | Execute login procedure, return (Right AccessToken) on success login :: Env LoginEnv -> IO (Either String AccessToken)-login e@(Env (LoginEnv _ acr cid) _ _ _) = - runVK e $ loop [0..] (vk_start_action cid acr) where +login e@(Env (LoginEnv _ acr cid) _ _ _) =+ runVK e $ loop [0..] (vk_start_action cid acr) where loop (n:ns) (AH h act) = do when_trace $ printf "VK => %02d %s" n (show act) ans@(p,c) <- vk_move act