I'm having trouble using the API to view a segment. I'm using PHP. My code is as follows:
$url = "https://us7.api.mailchimp.com/export/1.0/list/?apikey=$api_key&id=$list_id&$segment";
$result = file_get_contents($url);
where $segment is an array used to generate the segment.
I can get the following version working...
$segment = "segment[match]=all"
"&segment[conditions][0][field]=LNAME".
"&segment[conditions][0][op]=like".
"&segment[conditions][0][value]=smith";
which generates a segment of all subscribers to my list with a last name containing "smith".
However, what I actually want to do is generate a segment based on people who've been sent any mailer in the last 7 days. I've created this manually to get the correct fields and generated the following array based on it:
$segment = "segment[match]=all".
"&segment[conditions][0][condition_type]=Aim".
"&segment[conditions][0][field]=aim".
"&segment[conditions][0][op]=sent".
"&segment[conditions][0][value]=last7day";
but it's giving me a 300 error. This isn't listed in MailChimp's current error glossary on the export api documentation, but according to a snapshot of the old error documentation means "Campaign doesn't exist" (https://web.archive.org/web/20130209144951/https://apidocs.mailchimp.com/api/1.3/exceptions.field.php) which is weird because I'm not referencing a campaign.
What am I doing wrong?
// , Click on playground and with your API key.
Generate some responses and look at the campaign id.
It's not the integer value you see when hovering over the campaign with id=, it's another value.
Look for the id that the API needs in the response.
This will fix your issue.
hi i create one custom page in WordPress like page-download.php
i access this page like
http://example.com/download
its word fine but i want access this page like
http://example.com/download?n=skype
http://example.com/download?n=firefox
etc every time n value change.
and also i want get n value in page-download.php
please tell me how to do it . i know how to work in php simple but in wordpress its not work
Why just not use, echo $_GET['n'] ?
When you hit this page directly from the URL like below, please change your parameter, because of that I have tried same method few days ago and I can't get the parameter value.
http://example.com/download?from_browser=skype
http://example.com/download?from_browser=firefox
You can get the value like below or as per the reference :
$blah = get_query_var( 'from_browser');
if(isset($blah)) // Your code will be here
Hope this help!!!
Here is the scenario that i am working with and currently stuck at a point.
Joomla article calls a HTML form using sourcerer plugin.
SO in the article i have something like
[source] << include form.html >> [/source]
On submit, Form.html send a AJAX POST call to a PHP file updates a Db table and then opens a new URL which is a payment gateway.
<-- This is where my problem lies -->
I need to give return URL to my payment gateway so that after successful payment it redirects to this page along with the transaction id as a parameter in URL.(For ex : www.mywebsite.com/thank-you/?trxid=131213&uniqueid=23424234 )
I need to capture this transaction id and print it in the article saying "Thank you for your payment. Your transaction id is xxxxxxxx ".
How should i proceed with the development ? How can i capture the POST / GET parameters in the Joomla article ?
Can anyone help me here?
Thanks in advance.
BR
Nilesh
If you are already using Sourcerer in your articles you should be able to embed your PHP code between your [sourcerer][/sourcerer] tags. The following PHP code will all you to query the post variables in your URL:
$JInput = JFactory::getApplication()->input;
$trxid = $JInput->get('trxid','','int');
$uniqueid = $JInput->get('uniqueid','','int');
That will set your values to the variables $trxid and $uniqueid. From there you can print them in your article using the sourcerer tags and an echo or print statement.
Change the 'int' to 'string' if those fields may be alphanumeric mixed strings.
Cheers and Good Luck
Here is the link for the Joomla documentation on using JInput as well for future use if you need it. Using JInput with Joomla
I'm creating an autocomplete in Laravel 4 using twitter typeahead, but I'm having problems in the matching process.
The JS code:
$('#autocomplete').typeahead({
limit: 20,
name: 'destinatari',
prefetch: '{{URL::to("alumni/posta/utenti")}}',
remote: '{{URL::to("alumni/posta/utenti")}}'
});
The model populates the array like this:
public static function jsonList($idLogged)
{
$users = DB::table('users_data')
->where('userid', '!=', $idLogged)
->select('nome', 'nome_2', 'cognome', 'cognome_2', 'userid')
->orderBy('cognome', 'asc')
->orderBy('nome','asc')
->get();
$i = 0;
$ordered = array();
foreach($users as $u) {
$ordered[$i]['value'] = $u->nome.' '.$u->nome_2.' '.$u->cognome.' '.$u->cognome_2;
$ordered[$i]['tokens'] = array($u->nome, $u->cognome);
$ordered[$i]['userid'] = $u->userid;
$i++;
}
return $ordered;
}
And my controller simply:
return Response::json( Users::jsonList($this->userdata->id) );
The returned json (I see it in Firebug) looks like:
[{"value":"Silvia Miriam Abeyta Carretero","tokens":["Silvia","Abeyta"],"userid":"246"},
{"value":"Malak Julia Abreu Garrido","tokens":["Malak","Abreu"],"userid":"198"},{"value":"Aina Aguado ","tokens":["Aina","Aguado"],"userid":"243"},
{"value":"Jordi Alarc\u00f3n ","tokens":["Jordi","Alarc\u00f3n"],"userid":"308"},
{"value":"Aaron Nerea Alejandro ","tokens":["Aaron","Alejandro"],"userid":"49"},
{"value":"Alexia Alem\u00e1n ","tokens":["Alexia","Alem\u00e1n"],"userid":"306"},
{"value":"Salma Almaraz ","tokens":["Salma","Almaraz"],"userid":"54"},
{"value":"Alma Almonte Nev\u00e1rez","tokens":["Alma","Almonte"],"userid":"101"},
{"value":"Daniela Almonte ","tokens":["Daniela","Almonte"],"userid":"184"}
,....other similar results....]
The problem is that any letter I type only the first name in the list gets autocompleted ("Silvia Miriam Abeyta Carretero") in the input field, but when I type out in full any other name (say, "Daniela Almonte") the field isn't completed and the dropdown keeps showing the whole 20 results, without processing of any kind.
I must say, though, that if I click on a name it gets selected correctly (I'm logging the userid property of the datum ), but still the autocompletion isn't working.
What puzzles me is that If I copy/paste the whole list directly in the JS (taken as is from Firebug), as local property of typeahead() (instead of remote), everything works fine as it should.
What could be causing this? Is it a Laravel response problem? Or is it the typeahead processor (I believe it's in "transport.js" source file, uses jQuery $.ajax()) of the remote url?
It seems like the returned JSON is considered as a single entry, i don't know why since it looks correct to me...
From the typeahead documentation:
$('input.twitter-search').typeahead({
name: 'accounts',
prefetch: 'https://twitter.com/network.json',
remote: 'https://twitter.com/accounts?q=%QUERY'
});
As you can see, the remote parameter must contains the URL with the query parameter.
PHP side, you have to test if the parameter "q" is set and then adapt your request (with a LIKE statement by example) to correctly filter the list.
Otherwise, you can try to remove this remote parameter, maybe it would work with only the prefetch attribute.
How get google search results url?
(I use Zend_Gdata_Gbase for get search google results and not DomDocument/htmlsimpleparser because its looks to me that Zend_Gdata_Gbase done specially for parsing google results.
if I wrong in my selection, please write.)
My function to get google search results for 'yahoo' or other query search string:
(the function get a feed that should have search result for word 'yahoo', but when i use prin_t($feed) I don't see url for each result)
<?php
function queryGoogleSearch($queryString='yahoo'){
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('['.$queryString.']');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('4');
$feed = $service->getGbaseSnippetFeed($query);
return $feed;
}
print_r(queryGoogleSearch());
?>
I get 4 first url results (when I search manually in google):
www.yahoo.com, mail.yahoo.com, search.yahoo.com, maps.yahoo.com
But I can't find them when I print $feed variable.
Please what should i change or add inqueryGoogleSearch() function? (Or other better code)
Thanks
Are you trying to search google.com. Looks like that class is for Google Base, not google.com search engine. http://base.google.com/support/bin/answer.py?hl=en&answer=59260
You probably want this: http://code.google.com/apis/customsearch/v1/overview.html
They recently just changed this. The old google search API has now deprecated as of Nov 1st. Custom search is the new API.
Its pretty simple to use without Zend.
http://code.google.com/apis/customsearch/v1/using_rest.html#WorkingResults
There is a JSON decoder in PHP.
http://php.net/manual/en/function.json-decode.php
Hope that helps!