Skip to content

Instantly share code, notes, and snippets.

View hiraq's full-sized avatar

Hiraq Citra M hiraq

  • RuangGuru
  • Indonesia
View GitHub Profile
@hiraq
hiraq / gist:2171638
Created March 23, 2012 15:16
How to use php-amazon-pa-wrapper
<?php
define('ROOT',dirname(__FILE__));
define('DS',DIRECTORY_SEPARATOR);
ini_set('display_errors','On');
error_reporting(-1);
function debug($var) {
echo '<pre>';
@hiraq
hiraq / gist:2177610
Created March 24, 2012 02:19
Library installations
<?php
define('ROOT',dirname(__FILE__));
define('DS',DIRECTORY_SEPARATOR);
//add my library folder into your include_path
set_include_path(get_include_path().PATH_SEPARATOR.ROOT.DS.'php-amazon-pa-wrapper');
require_once 'Amazon.php';
use AmazonProductAdvertising\Amazon as Amazon;
@hiraq
hiraq / gist:2177663
Created March 24, 2012 02:29
How to use - Search Operation
<?php
/*
* set operations
*/
$amazon->request()->search('php');
$amazon->request()->setParams(array(
'SearchIndex' => 'Books',
'ResponseGroup' => 'Large'
));
@hiraq
hiraq / gist:2177669
Created March 24, 2012 02:31
ItemLookup operation
<?php
/*
* set operations
*/
$amazon->request()->detail('0596157134');
$amazon->request()->setParams(array(
'ResponseGroup' => 'Large'
));
@hiraq
hiraq / gist:2177708
Created March 24, 2012 02:40
Amazon Error Request
<?php
$is_valid = $amazon->response()->isRequestValid();
if(!$is_valid) {
//get error type and messages
debug($amazon->response()->getErrors());
}
@hiraq
hiraq / gist:2873261
Created June 5, 2012 07:09
Jhistory - how to use
jQuery(document).ready(function() {
jQuery('#testSbWidget').jhistory();
});
@hiraq
hiraq / gist:2873287
Created June 5, 2012 07:16
Jhistory - work with browser back and forward button
jQuery(document).ready(function() {
jQuery(window).on('popstate',function(event) {
event.preventDefault();
var eventData = event.originalEvent.state;
if(eventData === null) {
jQuery('#content').html('');
}else{
@hiraq
hiraq / cloggy_activation
Last active December 11, 2015 00:19
Place this code at app/Config/bootstrap.php. Don't forget to import Cloggy main sql at app/Plugin/Cloggy/Config/sql/cloggy_main.sql and set your cakephp database configurations
CakePlugin::load(array(
'Cloggy' => array(
'routes' => true,
'bootstrap' => true
)
));
@hiraq
hiraq / cloggy_register_module
Created January 12, 2013 02:27
You can edit this code at app/Plugin/Cloggy/Config/bootstrap.php line 10. Remember, your module folder name must be match with your module name.
//setup registered modules
Configure::write('Cloggy.modules',array(
'CloggyBlog','CloggyUsers','ModuleTest'
));
@hiraq
hiraq / fix_error_redirect_referer_proxy.php
Last active December 17, 2015 17:19
fix error redirect by referer, when running on proxy server (HTTP_X_FORWARDED_HOST has been set)
<?php
/*
* fix redirect because proxy server
*/
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_X_FORWARDED_HOST'] = isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
}