11<?php
22
3- namespace Actions \MdwikiApi ;
3+ namespace APICalls \MdwikiApi ;
44/*
55Usage:
6- use function Actions \MdwikiApi\get_mdwiki_url_with_params;
6+ use function APICalls \MdwikiApi\get_mdwiki_url_with_params;
77*/
88
99use function TD \Render \TestPrint \test_print ;
@@ -13,18 +13,22 @@ function post_url_mdwiki(string $endPoint, array $params = []): string
1313 $ usr_agent =
"WikiProjectMed Translation Dashboard/1.0 (https://mdwiki.toolforge.org/; [email protected] ) " ;
1414
1515 $ ch = curl_init ();
16-
17- curl_setopt ($ ch , CURLOPT_URL , $ endPoint );
18- curl_setopt ($ ch , CURLOPT_POST , true );
19- curl_setopt ($ ch , CURLOPT_POSTFIELDS , http_build_query ($ params ));
20- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
21- // curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
22- // curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
23- curl_setopt ($ ch , CURLOPT_USERAGENT , $ usr_agent );
24- curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , 5 );
25- curl_setopt ($ ch , CURLOPT_TIMEOUT , 5 );
26-
16+ // ---
17+ curl_setopt_array ($ ch , [
18+ CURLOPT_URL => $ endPoint ,
19+ CURLOPT_POST => true ,
20+ CURLOPT_POSTFIELDS => http_build_query ($ params ),
21+ CURLOPT_RETURNTRANSFER => true ,
22+ CURLOPT_USERAGENT => $ usr_agent ,
23+ CURLOPT_CONNECTTIMEOUT => 5 ,
24+ CURLOPT_TIMEOUT => 5 ,
25+ // لاستخدام ملفات الكوكيز عند الحاجة:
26+ // CURLOPT_COOKIEJAR => "cookie.txt",
27+ // CURLOPT_COOKIEFILE => "cookie.txt",
28+ ]);
29+ // ---
2730 $ output = curl_exec ($ ch );
31+ // ---
2832 $ url = "{$ endPoint }? " . http_build_query ($ params );
2933 // ---
3034 // remove "&format=json" from $url then make it link <a href="$url2">
0 commit comments