Discuss Small class based on an API - need "evaluation" in the PHP Development forum on Dev Shed. Small class based on an API - need "evaluation" PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Posts: 2,222
Time spent in forums: 2 Weeks 1 Day 9 h 5 m 25 sec
Reputation Power: 201
Small class based on an API - need "evaluation"
I am creating a class for the first time so wanted your thoughts on what i have so far.. (its not complete) as i do not want to go down the wrong road if what i have done is not ok...
if you need the API then please let me know..
thanks
PHP Code:
class API {
public $method = "POST";
public $content_type = "application/x-www-form-urlencoded";
private $key = "key";
private $media_code_id = "";
private $api_errors = array (
"Invalid API Key" => "The API Key provided is invalid",
"Not authorized" => "Your IP Address is not authorised to access this API."
);
private $url = "url";
private $media_code_url = "mediacodes/create";
private $post_contact_url = "contacts/create";
private $post_data = ""; //used to hold user data that needs to be sent across into the request. this has been run through the function http_build-query..
private $user_input = ""; //this is the actual data from the user
public function __construct($data){
$this->user_input = $data;
}
public function check_user_input(){
//if the key doesnt exist in parameter, throw it away!
foreach ($this->user_input as $key => $value){
if (!isset($this->parameters[$key])){
unset($this->user_input[$key]);
}
}