Archive for 'PHP'
Five common PHP design patterns
Hi All
I hope this article will help you guys a lot with some basic stuff we could use in designing applications or rather you do re-factoring in your code.
Main design pattens discussed in this article are listed below
- The factory pattern
- The singleton pattern
- The observer pattern
- The chain-of-command pattern
- The strategy pattern
Posted on 24 December '09 by Priyantha, under PHP, Software Engineering. No Comments.
Get All keywords in Adword v200909 in PHP
I hope this will help you guys when working with adword new API. I just completed this function and thought of sharing it for you all. I couldn’t find any PHP code in the net to do the same.
Cheers,
Priya.
——————————————————————
class GetAllKeywordsExample {
static function main($keywords_input, $match_type) {
$return_array = array();
try {
// Get AdWordsUser from credentials in “../auth.ini”
// relative to the AdWordsUser.php file’s directory.
$user = new AdWordsUser();
// Log SOAP XML request and response.
$user->LogDefaults();
// Get the TargetingIdeaService.
$keywordService = $user->GetTargetingIdeaService();
$keyword = new Keyword();
$keyword->text = $keywords_input;
$keyword->matchType = $match_type;
$keyword_array = array($keyword);
$relatedToKeywordSearchParameter = new RelatedToKeywordSearchParameter($keyword_array);
$targetingIdeaSelector = new TargetingIdeaSelector();
$targetingIdeaSelector->searchParameters = array(
$relatedToKeywordSearchParameter
);
$targetingIdeaSelector->ideaType = ‘KEYWORD’;
$targetingIdeaSelector->requestType = ‘IDEAS’;
$targetingIdeaSelector->paging = new Paging(0,800);
// Get all Keywords.
$keywordPage = $keywordService->get($targetingIdeaSelector);
// Prepare keyword array.
if(isset($keywordPage->entries)) {
foreach ($keywordPage->entries as $keyword_entry) {
foreach($keyword_entry as $keyword_entry_array){
/*
*/
//var_dump($keyword);
foreach ($keyword_entry_array as $keyword){
if($keyword->key == ‘KEYWORD’){
$keyword_value = $keyword->value;
if($keyword_value->value->matchType == $match_type){
$return_array[] = array(
‘keyword’=>$keyword_value->value->text
);
}
}
}
}
}
} else {
throw new Exception(”ERROR”,0);
}
} catch (Exception $e) {
$return_array[] = array(
‘keyword’=>$e->getMessage());
}
return $return_array;
}
}
——————————————————-
Posted on 3 November '09 by Priyantha, under PHP. 6 Comments.
Bug #40886 static methods assigned to instances
I found a nice article that debating about the static method implementation in PHP. Guys who are interesting may read it…
Setting Up a Web-Based File Manager: bfExplorer
Everybody knows how to use a conventional desktop application that acts as a file manager. And we all know how useful these manipulation utilities really are. They give us a hierarchical view of the content of our folders. They also have dozens of extra functions. In this series, we’re going to see how we can do this on a web server. We will present two freeware PHP-based file managers. You’ll find out how to install and configure them.
Posted on 15 April '08 by Priyantha, under MySQL, PHP. No Comments.
















