I am using adsense Management API and followed everything there to generate a demo report as it is described in the example on their site.
The information I am currently fetching uses this information :
$startDate = '2012-03-01';
$endDate = '2012-04-18';
$optParams = array(
'filter' => array(
'AD_CLIENT_ID==' . $adClientId
),
'metric' => array(
'CLICKS', 'PAGE_VIEWS','COST_PER_CLICK','EARNINGS'
),
'dimension' => array('DATE'),
'sort' => 'DATE'
);
What I have to ask is is it possible to arrange this data according to the channels So that I get channel-wise information on EARNING, COST_PER_CLICK and PAGE_VIEWS. And how?
Assuming you're talking about custom channels, all you have to do is add one of the following to your list of dimensions, depending on what you prefer:
CUSTOM_CHANNEL_NAME
CUSTOM_CHANNEL_ID
CUSTOM_CHANNEL_CODE
You can think of dimensions as groups, that is, what you're organising your data by.
You can check this blog post for some more info.
Related
I am working with the Church Community Builder API (official docs, search for "group profile" to see relevant code) and with CCB Core WordPress Plugin to sync groups data from the API into custom post types (fields, taxonomies).
CCB Core maps a lot of this data automatically, but it doesn't map the group ID value CCB uses to distinguish one group from another and I'd like to sync it.
The relevant code is kept in the functions get_groups_custom_fields_map() and get_groups_taxonomy_map().
I've tried adding something like the following to get_groups_taxonomy_map():
'group_id' => array (
'api_mapping' => 'group',
'data_type' => 'integer',
),
But this doesn't work. Any suggestions on writing code to pull in this field?
UPDATE 9/10/16 7:25 PM:
I think I am wicked close.
I took the XML from the API documentation under Group Profile and ran it through simplexml and generated this output.
I then compared the output with how the get_groups_custom_fields_map and get_groups_custom_taxonomy_map was organized, which led me to believe the following should work:
'group' => array (
'api_mapping' => 'group',
'data_type' => 'object',
'child_object' => array(
'api_mapping' => '#attributes',
'data_type' => 'object',
'child_object' => array(
'group_id' => array(
'api_mapping' => 'id',
'data_type' => 'integer'
)
)
)
),
But it doesn't. What am I missing?
The SimpleXML representation of the response that comes back from CCB just so happens to have a really frustrating way of deserializing the IDs for the entities (Groups, Events, Individuals, etc) that come out of the API. (And it only happens on the IDs).
Even though Group ID looks like a property in the XML response string, it's actually an attribute which is slightly different. In your object response, notice that # symbol in the [#attributes] node. PHP will not allow direct access to that.
See "At sign" # in SimpleXML object?
As a workaround I actually obtain the Group ID like so right here:
https://github.com/jaredcobb/ccb-core/blob/1a6e88b47ad7d5293e88bac277e72cbc4e33a602/admin/class-ccb-core-sync.php#L589-L595
Code snippet of the above reference:
$group_id = 0;
foreach( $group->attributes() as $key => $value ) {
if ( $key == 'id' ) {
$group_id = (int) $value;
break;
}
}
So in general, we do have access to that group id, we just need to now save it as post meta. I'll update the plugin to take advantage of these IDs, but in the mean time you can use the $group_id variable directly and save the post meta in this function.
I'm using the PHP sdk to do image searches
$service = new Google_Service_Customsearch($client);
$optParams = array(
'imgType' => 'photo',
'imgColorType' => 'color',
'imgSize' => 'large',
'searchType' => 'image',
'num' => '5',
'safe' => 'medium',
'rights' => '(cc_publicdomain|cc_attribute|cc_sharealike)',
'filter' => '1',
'cx' => <my cx>,
);
$results = $service->cse->listCse($query, $optParams);
but i'm unclear that the "rights" field is doing anything.
It seems to generating a curl request that looks like this...
https://www.googleapis.com/customsearch/v1?
q=<query here>
&imgType=photo
&imgColorType=color
&imgSize=large
&searchType=image
&num=6
&safe=medium
&rights=%28cc_publicdomain%7Ccc_attribute%7Ccc_sharealike%29
&filter=1
&cx=<my cx>
but i'm not clear that is working the way i expect. my query returns different images then when I use the web form.
Additionally the docs unhelpfully states..
rights | string | Filters based on licensing. Supported values include:
| | cc_publicdomain, cc_attribute, cc_sharealike, cc_noncommercial,
| | cc_nonderived, and combinations of these.
however i never get an error with this field, i can put any junk i want into it.
what is the proper format google expects here? comma delimited? array? piped ?
Also, the options listed in the docs do not seem to match up precisely with the options in the web form, and some insights there would be nice too.
You can see here for licencing of custom search
https://developers.google.com/custom-search/docs/structured_search#licensing
I have been trying to set up an automated script to pull from a RETS server using PHP and I can not get the PHRets search to return anything. My query is below:
/* Search RETS server */
$search = $rets->SearchQuery(
'Property', // Resource
3, // Class
'(LastTransDate_f77=2013-01-01+)', // DMQL
array(
'Format' => 'COMPACT-DECODED',
'Select' => 'AREA_f16',
'Count' => 1,
'Limit' => 20,
)
);
EDIT: I got this working finally. The problem had nothing to do with my code, however, it was in the MLS board's faulty documentation. The documentation said that I could select certain fields for certain property types, but that wasn't the case. I had to consult a third party developer and get the list of fields/column names that he had used.
Consult the PHRETS documentation. You have the second parameter as an integer. It should be a string. Also the comma needs to be removed after the last element in the array.
/* Search RETS server */
$search = $rets->SearchQuery(
'Property',
'3',
'(LastTransDate_f77=2013-01-01+)',
array(
'Format' => 'COMPACT-DECODED',
'Select' => 'AREA_f16',
'Count' => 1,
'Limit' => 20
));
I want to create a small widget which displays the last 3 user registrations in PyroCMS.
What I actually need more specifically is how to get the last 3 registered user IDs, displaying user data would not be a problem.
Managed to get it working this way:
$this->load->driver('Streams');
$params = array(
'stream' => 'profiles',
'namespace' => 'users',
'limit' => '3'
);
$entries = $this->streams->entries->get_entries($params);
I try developing two filter which order a list of groupforumtopics by the amount of answers and the amount of likes. I know the function: countAnnotations('likes') and countComments() but i have no idea how to use them. I use a switch case and depending on the input i create the $options array.
$options = array(
'type' => 'object',
'subtype' => 'groupforumtopic',
'limit' => 10,
'container_guid' => $guid,
'full_view' => FALSE,
);
$content = elgg_list_entities($options);
Does someone have a tip or better a solution?
Elgg likes and replies are annotations. So you have to use elgg_list_entities_from_annotation_calculation(). Its better to ask these type of questions in the elgg community forum, so that it will be helpful for others too.