Commits

Maxim Moiseev  committed 1aff8c1

minor changes

  • Participants
  • Parent commits 410d32a

Comments (0)

Files changed (3)

File src/VkontakteAPI/Linq2vk.Tests/ApiTests.fs

         this.IsSome <| List.tryFind (fun (k, _) -> k = "fields") kvs
 
 
+    [<Test>]
+    [<Explicit>]
+    member this.GenerateLoginUrl () =
+        printfn "%s" <| Login.makeLoginUrl Settings.AppId 130L
+
+    [<Test>]
+    [<Explicit>]
+    member this.GenerateGetFriendsRequestUrl () =
+        let handle = Settings.Handle
+
+        let query = Query.init ()
+                    |> Query.add "method" "friends.get"                    
+
+        let queryString = Api.createQueryString handle query
+        printfn "%s?%s" Api.BaseUrl queryString
+
+

File src/VkontakteAPI/Linq2vk.Tests/Linq2vk.Tests.fsproj

     <Reference Include="System.Numerics" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Settings.local.fs" />
     <Compile Include="ApiTests.fs" />
   </ItemGroup>
   <ItemGroup>

File src/VkontakteAPI/Linq2vk/Api.fs

 
 module Api =
 
-    let BaseUrl = "http://api.vk.com/api.php?"
+    let BaseUrl = "http://api.vk.com/api.php"
     let SupportedFormat = "JSON"
     let SupportedVersion = "3.0"
 
         Expire : DateTime;
     }
 
+    module AuxKeys =
+
+        [<Literal>]
+        let ApiId = "api_id"
+        [<Literal>]
+        let Format = "format"
+        [<Literal>]
+        let Sig = "sig"
+        [<Literal>]
+        let Sid = "sid"
+        [<Literal>]
+        let Version = "v"
+
+        let All = [ApiId; Format; Sig; Sid; Version]
+
+
     [<AutoOpen>]
     module HelperFunctions =
 
             sortedQuery
                 |> Query.joinWith (fun (k, v) -> sprintf "%s=%s" k v)
                 |> (fun args -> sprintf "%d%s%s" (handle.Uid) args (handle.Secret))
+//                |> (fun s -> do Console.WriteLine(s)
+//                             s)
                 |> DataTools.md5
 
         let cleanQuery =
             let autogeneratedKeys =
-                Set.ofList ["api_id"; "format"; "sig"; "sid"; "v"]
+                Set.ofList AuxKeys.All
             let shouldRemain k =
                 not <| Set.contains k autogeneratedKeys
             Query.filterKeys shouldRemain
         let cleanQ = cleanQuery query
         let signature = createSignature handle cleanQ
         let auxArgs = [
-            ("app_id", string handle.AppId);
-            ("format", SupportedFormat);
-            ("sid", handle.Sid);
-            ("v", SupportedVersion);
-            ("sig", signature);
+            (AuxKeys.ApiId, string handle.AppId);
+            (AuxKeys.Format, SupportedFormat);
+            (AuxKeys.Sid, handle.Sid);
+            (AuxKeys.Version, SupportedVersion);
+            (AuxKeys.Sig, signature);
         ]
         let resultQ = cleanQ |> Query.addMany auxArgs
         Query.toQueryString resultQ