I don't know if I used the correct term in the "topic" but I need your help with advices, tips or tutorials that can show how can I create something similar to the following request:
let's say I have a database with username,password,balance with a php script that works fine managing users etc...
how can I create for ex:
http://domain/script.php?username=user1 ... getbalance
in this way anyone can use this http URL to get the balance from my database using his own script. this also applies to get other actions and tasks...
Thanks a million
get data from external script
Moderator: General Moderators
-
phpnewbie112
- Forum Newbie
- Posts: 6
- Joined: Tue Jun 17, 2008 3:11 pm
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: get data from external script
This statement is difficult to understand. Can you please expound?phpnewbie112 wrote:in this way anyone can use this http URL to get the balance from my database using his own script
-
phpnewbie112
- Forum Newbie
- Posts: 6
- Joined: Tue Jun 17, 2008 3:11 pm
Re: get data from external script
for example you create your own php code with let's say
$bal = "http://domain/script.php?username=user1 ... getbalance"
and when you do
echo $bal;
the result should be to retrieve the value of the balance. for sure database connection is to be included inside the 'script.php'
$bal = "http://domain/script.php?username=user1 ... getbalance"
and when you do
echo $bal;
the result should be to retrieve the value of the balance. for sure database connection is to be included inside the 'script.php'
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: get data from external script
You can use URI's with many PHP file functions. For instance:
Code: Select all
$contents = file_get_contents("http://mydomain/test.php");-
phpnewbie112
- Forum Newbie
- Posts: 6
- Joined: Tue Jun 17, 2008 3:11 pm
Re: get data from external script
sorry I did not understand could you pls clarify further in an example for the balance. thanks a million
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: get data from external script
You'll want to read the documentation for further clarification:
http://www.php.net/file_get_contents
http://www.php.net/file_get_contents
-
phpnewbie112
- Forum Newbie
- Posts: 6
- Joined: Tue Jun 17, 2008 3:11 pm
Re: get data from external script
I think you misunderstood me, I read the documentation about file_get_contents I don't think that's the needed. my request is kind of related to create an api for other users to get my data...
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: get data from external script
Well, what questions regarding coding an API do you have?