I understand that this part of the API is not implemented fully etc, etc. However I am having an issue I can't get around which is the following:
&prop is converted by php to the "proportional" char when sending via post, get, using curl, fopen, file_get_contents. This whole process works just fine if I execute via the URL in the browser, so I know it can happen. Is there a way around using &prop=info to get a token to complete the page creation process? Why is &prop being used when it's a reserved html special char? It seems silly to be blocked by such a little thing but I can't seem to get around it and would rather not do this whole thing is javascript since this script will have a lot of work to do when its complete. My assumption is that many people will run into this when the api becomes more popular, because who doesn't love php?
Thanks,
jason
--Info---
* MediaWiki: 1.12alpha
* PHP: 5.1.2 (apache2handler)
* MySQL: 5.0.18-log
---Begin PHP Code---
echo "<pre>";
print_r($_POST);
$apiURL = "http://%22.$_SERVER%5B%27HTTP_HOST%27%5D.%22/phpapps/wiki/api.php";
$loginURL = "action=login&lgname=jkuter&lgpassword=&lgdomain=ad.mathworks.com&format =php";
$getLoginResponse = unserialize(getURL($apiURL,$loginURL));
print_r($getLoginResponse);
$titleURL = "action=query&prop=info&titles=BatPresubmitTest&intoken=edit&lgtoken=".
$getLoginResponse['login']['lgtoken']."&lgusername=".
$getLoginResponse['login']['lgusername']."&lguserid=".
$getLoginResponse['login']['lguserid'].
"&format=php";
$getTitleResponse = unserialize(getURL($apiURL,$titleURL));
print_r($getTitleResponse);
$newPageURL = "action=query&prop=info&titles=BatPresubmitTest&intoken=edit&lgtoken=".
$getLoginResponse['login']['lgtoken']."&lgusername=".
$getLoginResponse['login']['lgusername']."&lguserid=".
$getLoginResponse['login']['lguserid'].
"&format=php";
//$makeNewPage = unserialize(getURL($apiURL,$newPageURL));
//print_r($makeNewPage);
echo "</pre>";
function getURL($url,$vars){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
---End PHP Code---
---Begin output with &prop---
Array
(
[RCAlink] => Insert link here
[ReqDesRevDoclink] => Insert link here
[LEGORevlink] => Insert link here
[APIClasslink] => Insert link here
[CRChecklistLink] => Insert link here
[CRList] => Insert list here
[TestsAddedDescription] => Insert description here
[RunSuiteList] => Insert list here
[InteractiveBashingList] => Insert list here
[BaTStages] => Insert list here
[ForeignFilesMissing] => Insert link here
[BuildPlatformsList] => Insert list here
[TestPlatformsList] => Insert list here
[TestingBottleneck] => YNTestingBottleneck
[FinalMergeCheck] => YNFinalMergeCheck
[SubmitJob] => YNSubmitJob
[JobNo] => dsfdsf
[Submit_Checklist] => Submit
)
Array
(
[login] => Array
(
[result] => Success
[lguserid] => 1004
[lgusername] => Jkuter
[lgtoken] => 4ee852dbbe6ad67022af0873aaa21098
[cookieprefix] => inside_wiki
[sessionid] =>
)
)
Array
(
[error] => Array
(
[code] => inpermissiondenied
[info] => Action 'edit' is not allowed for the current user
)
)
--End Output With &prop---
---Begin Output Without &prop---
Array
(
[RCAlink] => Insert link here
[ReqDesRevDoclink] => Insert link here
[LEGORevlink] => Insert link here
[APIClasslink] => Insert link here
[CRChecklistLink] => Insert link here
[CRList] => Insert list here
[TestsAddedDescription] => Insert description here
[RunSuiteList] => Insert list here
[InteractiveBashingList] => Insert list here
[BaTStages] => Insert list here
[ForeignFilesMissing] => Insert link here
[BuildPlatformsList] => Insert list here
[TestPlatformsList] => Insert list here
[TestingBottleneck] => YNTestingBottleneck
[FinalMergeCheck] => YNFinalMergeCheck
[SubmitJob] => YNSubmitJob
[JobNo] => dsfdsf
[Submit_Checklist] => Submit
)
Array
(
[login] => Array
(
[result] => Success
[lguserid] => 1004
[lgusername] => Jkuter
[lgtoken] => 4ee852dbbe6ad67022af0873aaa21098
[cookieprefix] => inside_wiki
[sessionid] =>
)
)
Array
(
[query] => Array
(
[pages] => Array
(
[-1] => Array
(
[ns] => 0
[title] => BatPresubmitTest
[missing] =>
)
)
)
)
--End Output Without &prop---
Jason Kuter schreef:
I understand that this part of the API is not implemented fully etc, etc. However I am having an issue I can’t get around which is the following:
&prop is converted by php to the “proportional” char when sending via post, get, using curl, fopen, file_get_contents.
That's weird. Isn't the proportional character supposed to be "∝", with a semicolon? If CURL chokes on this, that's CURL's fault, not ours. Alternatively, you could use Snoopy [1], which doesn't have this problem.
Roan Kattouw (Catrope)
P.S.: Never, EVER, send HTML e-mail to a mailing list, unless you want lots of people to hate you. Your e-mail application is bound to have an option to send plain-text e-mail rather than HTML.
Sorry about the HTML email. Yes it appears that all php url handling functions run htmlspecialchars_decode() on open (and it makes no sense while it still decodes &prop without the ;). I can't seem to get around it and there is no reference to it within any doc or the php.ini file.
@Ran Ari-Gur Unfortunately replacing the & with & does not solve the problem.
I will try snoopy and see what happens, but this minor issue is killing me.
-jason
-----Original Message----- From: Roan Kattouw [mailto:roan.kattouw@home.nl] Sent: Tuesday, November 13, 2007 10:40 AM To: MediaWiki API announcements & discussion Cc: Jason Kuter Subject: Re: [Mediawiki-api] FW: Problems Using API Via PHP
Jason Kuter schreef:
I understand that this part of the API is not implemented fully etc, etc. However I am having an issue I can't get around which is the following:
&prop is converted by php to the "proportional" char when sending via post, get, using curl, fopen, file_get_contents.
That's weird. Isn't the proportional character supposed to be "∝", with a semicolon? If CURL chokes on this, that's CURL's fault, not ours.
Alternatively, you could use Snoopy [1], which doesn't have this problem.
Roan Kattouw (Catrope)
P.S.: Never, EVER, send HTML e-mail to a mailing list, unless you want lots of people to hate you. Your e-mail application is bound to have an option to send plain-text e-mail rather than HTML.
Try replacing those ampersands (&) with &.
http://www.w3.org/TR/html40/appendix/notes.html#h-B.2.2
-Ran
________________________________
From: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of Jason Kuter Sent: Tuesday, November 13, 2007 10:27 AM To: mediawiki-api@lists.wikimedia.org Subject: [Mediawiki-api] FW: Problems Using API Via PHP
I understand that this part of the API is not implemented fully etc, etc. However I am having an issue I can't get around which is the following:
&prop is converted by php to the "proportional" char when sending via post, get, using curl, fopen, file_get_contents. This whole process works just fine if I execute via the URL in the browser, so I know it can happen. Is there a way around using &prop=info to get a token to complete the page creation process? Why is &prop being used when it's a reserved html special char? It seems silly to be blocked by such a little thing but I can't seem to get around it and would rather not do this whole thing is javascript since this script will have a lot of work to do when its complete. My assumption is that many people will run into this when the api becomes more popular, because who doesn't love php?
Thanks,
jason
--Info---
* MediaWiki: 1.12alpha
* PHP: 5.1.2 (apache2handler)
* MySQL: 5.0.18-log
---Begin PHP Code---
echo "<pre>";
print_r($_POST);
$apiURL = "http://%22.$_SERVER%5B%27HTTP_HOST%27%5D.%22/phpapps/wiki/api.php";
$loginURL = "action=login&lgname=jkuter&lgpassword=&lgdomain=ad.mathworks.com&format=php ";
$getLoginResponse = unserialize(getURL($apiURL,$loginURL));
print_r($getLoginResponse);
$titleURL = "action=query&prop=info&titles=BatPresubmitTest&intoken=edit&lgtoken=".
$getLoginResponse['login']['lgtoken']."&lgusername=".
$getLoginResponse['login']['lgusername']."&lguserid=".
$getLoginResponse['login']['lguserid'].
"&format=php";
$getTitleResponse = unserialize(getURL($apiURL,$titleURL));
print_r($getTitleResponse);
$newPageURL = "action=query&prop=info&titles=BatPresubmitTest&intoken=edit&lgtoken=".
$getLoginResponse['login']['lgtoken']."&lgusername=".
$getLoginResponse['login']['lgusername']."&lguserid=".
$getLoginResponse['login']['lguserid'].
"&format=php";
//$makeNewPage = unserialize(getURL($apiURL,$newPageURL));
//print_r($makeNewPage);
echo "</pre>";
function getURL($url,$vars){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
---End PHP Code---
---Begin output with &prop---
Array
(
[RCAlink] => Insert link here
[ReqDesRevDoclink] => Insert link here
[LEGORevlink] => Insert link here
[APIClasslink] => Insert link here
[CRChecklistLink] => Insert link here
[CRList] => Insert list here
[TestsAddedDescription] => Insert description here
[RunSuiteList] => Insert list here
[InteractiveBashingList] => Insert list here
[BaTStages] => Insert list here
[ForeignFilesMissing] => Insert link here
[BuildPlatformsList] => Insert list here
[TestPlatformsList] => Insert list here
[TestingBottleneck] => YNTestingBottleneck
[FinalMergeCheck] => YNFinalMergeCheck
[SubmitJob] => YNSubmitJob
[JobNo] => dsfdsf
[Submit_Checklist] => Submit
)
Array
(
[login] => Array
(
[result] => Success
[lguserid] => 1004
[lgusername] => Jkuter
[lgtoken] => 4ee852dbbe6ad67022af0873aaa21098
[cookieprefix] => inside_wiki
[sessionid] =>
)
)
Array
(
[error] => Array
(
[code] => inpermissiondenied
[info] => Action 'edit' is not allowed for the current user
)
)
--End Output With &prop---
---Begin Output Without &prop---
Array
(
[RCAlink] => Insert link here
[ReqDesRevDoclink] => Insert link here
[LEGORevlink] => Insert link here
[APIClasslink] => Insert link here
[CRChecklistLink] => Insert link here
[CRList] => Insert list here
[TestsAddedDescription] => Insert description here
[RunSuiteList] => Insert list here
[InteractiveBashingList] => Insert list here
[BaTStages] => Insert list here
[ForeignFilesMissing] => Insert link here
[BuildPlatformsList] => Insert list here
[TestPlatformsList] => Insert list here
[TestingBottleneck] => YNTestingBottleneck
[FinalMergeCheck] => YNFinalMergeCheck
[SubmitJob] => YNSubmitJob
[JobNo] => dsfdsf
[Submit_Checklist] => Submit
)
Array
(
[login] => Array
(
[result] => Success
[lguserid] => 1004
[lgusername] => Jkuter
[lgtoken] => 4ee852dbbe6ad67022af0873aaa21098
[cookieprefix] => inside_wiki
[sessionid] =>
)
)
Array
(
[query] => Array
(
[pages] => Array
(
[-1] => Array
(
[ns] => 0
[title] => BatPresubmitTest
[missing] =>
)
)
)
)
--End Output Without &prop---
mediawiki-api@lists.wikimedia.org