SugarCRM rest API order by not working - php

I try to sort records returned by the get_entry_list rest api method, and it doesn't working.
Request JSON:
{
"session":"mj95dgk1ldtd2m96u02oj0u3r2",
"module_name":"Accounts",
"query":"accounts.name LIKE 'Air%'",
"order_by":"accounts.name desc",
"offset":0,
"select_fields":[
],
"link_name_to_fields_array":"",
"max_result":100,
"deleted":0,
"favorites":false
}
I'm using api version 4.1.
Results are not sorted even using ASC or DESC sorting method.

Manage to solve the problem based on this link
https://web.sugarcrm.com/support/issues/806c9fb3-6712-abd6-3106-5287d5398699
Proposed fix:
in service/v4/SugarWebServiceUtilv4.php
Around line 89: remove or comment the following line:
$order_by=$seed->process_order_by($order_by, null);
It certainly would be better to fix that in SugarBean.php (process_order_by) where the following test was removed:
if (strchr($value,'.') === false)

it seems like this is bug in sugar crm ( Bug :59526 ) .
order by not working with web service
But you can also fetch the record by creating your own method for Api , i hope this helps !

Related

Google Search Console API multiple dimensions

I am having a small problem adding multiple dimensions to the API request for Search Console.
If I add the following to group by country it works fine.
$filters->setDimension("country");
$filters->setOperator("equals");
$filters->setExpression($country);
$filter->setFilters($filters);
$filter->setFilters(array($filters));
$request->setDimensionFilterGroups(array($filter));
But if I add another dimension below for device, it skips the country dimension and only runs the query with the device dimension. It's perfectly possible to run both according to this on the search console API site:
'filters': [{
'dimension': 'country',
'expression': 'ind'
}, {
'dimension': 'device',
'expression': 'MOBILE'
}]
So, any idea how I can use them both on a query?
It's probably simply some PHP code, but I can't find any documentation on multiple dimensions or any examples anywhere with PHP in mind.
It was simple.
$filters->setDimension("country");
$filters->setOperator("equals");
$filters->setExpression($country);
$filters2->setDimension("device");
$filters2->setOperator("equals");
$filters2->setExpression($device);
$filter->setFilters($filters);
$filter->setFilters(array($filters,$filters2));
$request->setDimensionFilterGroups(array($filter));
Works like a charm.
Many thanks for sharing this, Nick - it really helped!
One tiny thing: you won't need the following:
$filter->setFilters($filters);
as you're setting filters the right way with the next line of code.
Also, I was stuck on the following line:
$request->setDimensionFilterGroups(array($filter));
as I was passing the $filter object as it is instead of using an array.
I really found this counter-intuitive: this is the only object setDimensionFilterGroups method needs; I'm still wondering why it needs an array instead.
Cheers,
Sal
Nick's answer did helped me start but currently it isn't complete. To help other devs looking for an answer, hope this would help you:
$filter_group = new Google_Service_Webmasters_ApiDimensionFilterGroup;
$groups = array(['device', 'mobile', 'equals'], ['country', 'GBR', 'equals']);
$filters = array();
if($groups) {
foreach ($groups as $key => $group) {
$filters[$key] = new Google_Service_Webmasters_ApiDimensionFilter;
$filters[$key]->setDimension($group[0]);
$filters[$key]->setExpression($group[1]);
$filters[$key]->setOperator($group[2]);
}
$filter_group->setFilters($filters);
}
$request->setDimensionFilterGroups(array($filter_group));
Also take note, currently it won't work if in your filter group you have two or more same dimension but different value for filter or expression.
e.g.
$groups = array(['device', 'mobile', 'equals'], ['device', 'tablet', 'equals']);
It is because OR operation is currently not supported for filters.
Check here and this answer here.

facebook api marketing create campaign issue

I would like to create a campaign using Facebook API. I tried to run all available example without success.
First of all I created an App in order to have a APP_ID and a APP_SECRET.
I did all the procedure to add my Ad_account following the tutorial.
I downloaded all the SDK to facilitate Facebook API use like:
facebook-php-ads-sdk and run adgroup_creation.php and curl_log.php with my data, without success.
facebook-php-sdk-v4 I suppose it is less specific than the previous one.
Multi-Product Ads with the Facebook Marketing POST -> developers.facebook.com/ads/blog/post/2015/03/26/creating-multi-product-ads/
the developers reference -> developers.facebook.com/docs/reference/php/4.0.0
I used "Composer" to get all dependency.
In all this case I had problem to create a campaign using more or less this code:
$campaign = new \FacebookAds\Object\AdCampaign(null,"act_$ACCOUNT_ID");
$campaign->setData(array(
AdCampaignFields::NAME => 'My First Campaign',
AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS,
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED ));
// PROBLEM is Here
$campaign->create();
Any help? How can I get a more useful error?
It's difficult to help without knowing the exact error. However, you could try this: before creating your campaign, initialize the API using:
Api::init(<your_app_id>, <your_ap_secret>, <your_token>);
(You need to load FacebookAds\Api to use this function).

PHRets using POST

I'm using PHRets and trying to return some search results. Below is the code, which is very basic and should work:
include('../include/common.php');
include('../classes/phrets.php');
$rets = new phRETS();
$connect = $rets->connect(RETS_LOGIN_URL, RETS_USERNAME, RETS_PASSWORD);
if($connect){
$search = $rets->SearchQuery('PROPERTY', 'RES', '((COUNTY=Dallas))', array('LIMIT'=>20));
print_r($rets->Error());
echo $rets->TotalRecordsFound($search);
$rets->Disconnect();
}else{
$error = $rets->Error();
print_r($error);
}
When I run the page, I receive the following error:
Array ( [type] => rets [code] => 20203 [text] => The request limit is too large for a GET. Please use the POST method to submit your search. ) 0
I don't see a parameter to force PHRets to send the request as a POST. Will this require a hack of the class, or am I missing something?
Thanks
EDIT: I just heard back from the developer. It's not supported at this time. Perhaps a less-busier person should clone it and work on that.. :) Anyway, if anyone has already has modified the code to make this work, let me know, please.
Get the latest phRETS version which supports POST method from here and replace with your old phrets.php.
then you need to add an extra line to the script
$rets->SetParam('use_post_method', true);
Note: By default it will be GET method.
I've published an updated version supporting POST searches available at https://github.com/nathanklick/PHRETS or via composer by adding "nathanklick/phrets": "1.0.2" to your composer.json file.

How to use Filestore in API in Agiletoolkit?

i am working on an urgent project which involves implmentation of filestore of Agiletoolkit
i went through the doc here => http://agiletoolkit.org/doc/filestore
$f=$p->add('Form');
$c=$p->add('Controller_Filestore_File');
$c->setActualFields(array('id','filestore_type_id','filestore_volume_id','filename','filesize'));
$f->addField('upload','upload')->setController($c);
$p->add('H4')->set('Previously Uploaded Files');
$g=$p->add('MVCGrid')->setController($c);
$g->dq->limit(5)->order('id desc');
there is this example there
Questions:
Q1. I know i don't need to use MVCGrid addon here but why is it mentioend in this example? (its confusing me )
Q2. Filestore is a controller i get that .. so if i want it on multiple pages, do i add it in the API ?
Q3. If suppose i add something like that in api can i use it in all pages ? if yes then how ? $this->api-> WHAT ?
There was a small bug in filestore which is fixed now. So it should work fine. It was a bug in sql queries that were imported.

List Contacts from a group from Zend GData

and thanks for reading.
My problem is that I'm trying to get a list of contacts belonging to a group in GData using Zend_Gdata_Query.
Using
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full/?group=http://www.google.com/m8/feeds/groups/xxx...xxx/base/XXX');
$feed = $gdata->getFeed($query);
give me an "Unknown authorization header".
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full/');
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/XXX...XXX/base/XXX');
$feed = $gdata->getFeed($query);
is the same.
Obviously without that parameter I get all the contacts.
I already tried the first method with the parameter in the URL with a modified Extension to CakePHP core HttpSocket and it was working. So I suppose the problem is with Zend stripping out parameters from the url but I had no luck looking at the libraries.
Thanks for any help.
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/myemail%40gmail.com/base/xxxxxxxxxxxxxx');
xxxxxxxxxxxxxx = group ID
As above the max-results also works if you add it to the query string like so:
http://www.google.com/m8/feeds/contacts/default/full?max-results=1000
Note that even in the google documentation the only way of getting ALL results is by 'setting a high number' for the number of results returned. So you can never explicitly specify 'ALL'
I guess you are using 3-legged OAuth. Then you need to add next line before getFeed() called:
$gdata->getHttpClient()->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING);
It will solve "Unknown authorization header" error.
For me using
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/XXX...XXX/base/XXX');
returns another error: "Invalid value for group parameter: XXXXXXXXXX" and I still dunno how to fix it :(

Categories