MailChimp API listStaticSegments is always empty - php

I have created several static Segments in Mailchimp for a List.
I am writing some PHP to create campaigns, but I am stuck on a hurdle early on.
I am using v1.3 of the MailChimp API
$api = new MCAPI( $this->config['api_key'] );
$lists = $api->listStaticSegments( $list_id );
var_dump( $api );
var_dump( $lists );
Results:
object(MCAPI)[39]
public 'version' => string '1.3' (length=3)
public 'errorMessage' => string '' (length=0)
public 'errorCode' => string '' (length=0)
public 'apiUrl' =>
array (size=4)
'scheme' => string 'http' (length=4)
'host' => string 'api.mailchimp.com' (length=17)
'path' => string '/1.3/' (length=5)
'query' => string 'output=php' (length=10)
public 'timeout' => int 300
public 'chunkSize' => int 8192
public 'api_key' => string 'XXX' (length=XX)
public 'secure' => boolean false
array (size=0)
empty
I am expecting $lists to have 10 items in an array.
When I log into MailChimp and check the API Account API Keys page, I can see there are requests but there are no responses.

Ah ha. The problem was I had no static lists. The lists that I had created were dynamic segments (auto updating) , so therefore I must use campaignSegmentTest to generate the same criteria for the dynamic segments.
http://apidocs.mailchimp.com/api/1.3/campaignsegmenttest.func.php
Further research on the Google Mailchimp forum:
https://groups.google.com/forum/#!msg/mailchimp-api-discuss/63DLfYq7ydI/jyGASmUxK8AJ

Related

Zend route with unlimited parameters

I am using Zend 1.10. I am trying to create a route for unlimited variables like abc.com/var1/var2/var3 and so on.
Till now i have searched and find out that i can add route for each variable like
$route = new Zend_Controller_Router_Route(
'/emaillog/:var1',
array(
'controller' => 'emaillog', // The controller to point to.
'action' => 'index', // The action to point to, in said Controller.
':var1' =>null //default value if param is not passed
)
);
$frontController->getRouter()->addRoute('emaillogWithVar1', $route);
and for second variable,
$route = new Zend_Controller_Router_Route(
'/emaillog/:var1/:var2',
array(
'controller' => 'emaillog', // The controller to point to.
'action' => 'index', // The action to point to, in said Controller.
':var1' =>null, //default value if param is not passed
':var2' =>null //default value if param is not passed
)
);
$frontController->getRouter()->addRoute('emaillogWithVar2', $route);
But the work i going to do, can contain 1-∞ infinite variables.
So i want to have once route for unlimited variables.
Any help will be appreciated!
There is a way to get infinite params. For that you don't have to declare them.
Lest say the url is index/test/p1/p2/p3/p4/p5, now if you try the following inside IndexController:
public function testAction()
{
var_dump($this->getRequest());
}
You will get a dump of an instance of Zend_Controller_Request_Http, in that dump, you will see, 2 properties, _params & _pathInfo, Like:
protected '_pathInfo' => string '/index/test/p1/p2/p3/p4/p5' (length=26)
protected '_params' =>
array (size=5)
'controller' => string 'index' (length=5)
'action' => string 'test' (length=4)
'p1' => string 'p2' (length=2)
'p3' => string 'p4' (length=2)
'module' => string 'default' (length=7)
1st method: Now in _params, they will occur as key => value pairs, as long as they are even, the last odd param will be ignored. You can get these by(for example):
$params = $this->getRequest()->getParams();
unset($params['controller']);
unset($params['action']);
unset($params['module']);
$params = array_merge(array_keys($params), array_values($params));
var_dump($params);
Output:
array (size=4)
0 => string 'p1' (length=2)
1 => string 'p3' (length=2)
2 => string 'p2' (length=2)
3 => string 'p4' (length=2)
2nd Method: OR you can use _pathinfo to get the params using explode, like:
$path = $this->getRequest()->getPathinfo();
$params = explode('/', $path);
unset($params[0]);
unset($params[1]);
unset($params[2]);
var_dump($params);
Output:
array (size=5)
3 => string 'p1' (length=2)
4 => string 'p2' (length=2)
5 => string 'p3' (length=2)
6 => string 'p4' (length=2)
7 => string 'p5' (length=2)

How to integrate square with Laravel

I have an app in Laravel and I am following this tutorial. I cloned a sample repo from here and When I try to make a pyament form this, it gives me the following response
Caught exception!
Response body:
object(stdClass)[6]
public 'errors' =>
array (size=1)
0 =>
object(stdClass)[7]
public 'category' => string 'INVALID_REQUEST_ERROR' (length=21)
public 'code' => string 'VALUE_TOO_LOW' (length=13)
public 'detail' => string '`amount_money.amount` must be greater than 100.' (length=47)
public 'field' => string 'amount_money.amount' (length=19)
Response headers:
array (size=12)
0 => string 'HTTP/1.1 400 Bad Request' (length=24)
'Content-Type' => string 'application/json' (length=16)
'Vary' => string 'Origin, Accept-Encoding' (length=23)
'X-Content-Type-Options' => string 'nosniff' (length=7)
'X-Download-Options' => string 'noopen' (length=6)
'X-Frame-Options' => string 'SAMEORIGIN' (length=10)
'X-Permitted-Cross-Domain-Policies' => string 'none' (length=4)
'X-Xss-Protection' => string '1; mode=block' (length=13)
'Date' => string 'Sat, 29 Oct 2016 08:23:51 GMT' (length=29)
'Keep-Alive' => string 'timeout=60' (length=10)
'Strict-Transport-Security' => string 'max-age=631152000' (length=17)
'content-length' => string '161' (length=3)
It worked when i tried the sandbox.
How can I make square to charge any amount that is less than USD 100?
How can I validate the card i.e. in the form given in the github repo, they don't ask for card holder name?
How can I integrate other payment methods with square like cash or cheque?
It sounds like you are trying to make a web based point of sale. To answer your questions:
The minimum charge for Credit Cards, both in the Square Register app and the API is $1.00 (the 100 amount includes cents)
The cards are primarily validated with CVV and postal code, which you should see as required fields in the form.
At this time you cannot create payments for other tender types like cash or check through the API. (This is primarily because our transaction APIs are used for e-commerce exclusively, while custom point of sales are usually created with our Register APIs)

Amazon Advertising API get Node's products

I'm creating e-commerce shop with Amazon API integration.
The problem I faced with is I cannot get items from specific node.
So I've tried many ways to do that, last one was something like this:
$fields = array();
$fields['AssociateTag'] = "ItemSearch";
$fields['Condition'] = 'All';
$fields['Operation'] = 'ItemSearch';
$fields['Version'] = '2013-08-01';
$fields['BrowseNode'] = $catId;
$fields['ResponseGroup'] = "Images,ItemAttributes,Offers";
$fields['Service'] = 'AWSECommerceService';
$fields['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
$fields['AWSAccessKeyId'] = $this->accessKey;
After that call I have the output:
public 'Items' =>
object(SimpleXMLElement)[150]
public 'Request' =>
object(SimpleXMLElement)[139]
public 'IsValid' => string 'True' (length=4)
public 'ItemSearchRequest' =>
object(SimpleXMLElement)[138]
public 'BrowseNode' => string '1289481011' (length=10)
public 'Condition' => string 'All' (length=3)
public 'ResponseGroup' =>
array (size=3)
0 => string 'Images' (length=6)
1 => string 'ItemAttributes' (length=14)
2 => string 'Offers' (length=6)
So I can see my request, but no items were returned to me.
By the way, ItemLookup, ItemSearch with keywords and BrowseNode operations work just fine.
What can I do to get items from node with spicific ID without using keywords?
I figured out what happened. I didn't set SearchIndex when I point BrowseNode ID.
So there was no result.

Amazon PHP SDK Listing Objects

I have the need to display the bucket contents on my S3 and I am using Amazon's PHP SDK.
My code is simply
$objects = $s3->list_objects("mybucket",array("max-keys"=>5));
var_dump($objects);
The response I get from the server is very complicated for me to understand -
It's essence is
Object(CFResponse)[107]
public 'header' =>
array (size=11)
'x-amz-id-2' => string
...
public 'body' =>
object(CFSimpleXML)[106]
public '#attributes' =>
array (size=1)
'ns' => string 'http://s3.amazonaws.com/doc/2006-03-01/' (length=39)
public 'Name' => string 'cdneu.2yourfacecdn.com' (length=22)
public 'Prefix' =>
object(CFSimpleXML)[3]
public 'Marker' =>
object(CFSimpleXML)[105]
public 'MaxKeys' => string '5' (length=1)
public 'IsTruncated' => string 'true' (length=4)
public 'Contents' =>
array (size=5)
0 =>
object(CFSimpleXML)[104]
...
1 =>
object(CFSimpleXML)[103]
...
2 =>
object(CFSimpleXML)[102]
...
3 =>
object(CFSimpleXML)[101]
...
4 =>
object(CFSimpleXML)[100]
...
public 'status' => int 200
I believe the part under the 'Contents' is what I'm looking for but how do I access it ? I'm used to receiving arrays where I can figure out what the keys are and how to access but this here is difficult for me ,
Any guesses?
try this in order to list the key element of each object:
$s3 = new AmazonS3();
$objects = $s3->list_objects("YOUR BUCKET NAME",array("max-keys"=>5));
foreach ($objects->body->Contents as $item){
print_r($item->Key."");
}
You can access contents as follows
$contents = $objects['Contents'];

Which options can you pass as the third parameter of Mage::run()?

Magento is started by running Mage::run() in index.php. Mage::run has three parameters: $code, $type, and $options. The first two are well-documented but I can't find anything about the third: $options.
I did read somewhere that you can move your etc directory to another place, but what other options can I set? I hope I can set the theme package; that's what I have been looking for.
I haven't personally used the third argument but after some investigation I've found out that they are used to set the Mage_Core_Model_Config options:
I've made a var_dump with the options and it looks something like this:
//excerpt from var_dump() of Mage_Core_Model_Config_Options
protected '_data' =>
array
'app_dir' => string '/var/www/magento/app' (length=36)
'base_dir' => string '/var/www/magento' (length=32)
'code_dir' => string '/var/www/magento/app/code' (length=41)
'design_dir' => string '/var/www/magento/app/design' (length=43)
'etc_dir' => string '/var/www/magento/app/etc' (length=40)
'lib_dir' => string '/var/www/magento/lib' (length=36)
'locale_dir' => string '/var/www/magento/app/locale' (length=43)
'media_dir' => string '/var/www/magento/media' (length=38)
'skin_dir' => string '/var/www/magento/skin' (length=37)
'var_dir' => string '/var/www/magento/var' (length=36)
'tmp_dir' => string '/var/www/magento/var/tmp' (length=40)
'cache_dir' => string '/var/www/magento/var/cache' (length=42)
'log_dir' => string '/var/www/magento/var/log' (length=40)
'session_dir' => string '/var/www/magento/var/session' (length=44)
'upload_dir' => string '/var/www/magento/media/upload' (length=45)
'export_dir' => string '/var/www/magento/var/export' (length=43)

Categories