I'm working on this project which use GSC API. Everything's working fine but I'm stuck with one kind of query : I wanna group the result by Pages so I can get all the queries (or keywords) for each page.
here's what a request looks like :
public function getTopPages($sitename){
$this->client->setAccessToken($this->getStoredToken());
$searchRequest = new \Google_Service_Webmasters_SearchAnalyticsQueryRequest;
//last month from today
$searchRequest->setStartDate($this->getDateMinusMonths("-12 months")); //'YYYY-MM-DD'
$searchRequest->setEndDate(date("Y-m-d", time()));
$dimensions = ['page', 'query'];
$searchRequest->setDimensions($dimensions);
$searchRequest->setRowLimit(10);
$searchRequest->setAggregationType('byPage');
$siteQueries = $this->webmaster->searchanalytics->query($sitename, $searchRequest);
if (count($siteQueries) > 0) {
$siteQueries = $siteQueries->getRows();
if ($siteQueries) {
return $siteQueries;
}
}
}
I tried to change the aggregationType property but it doesnt changed the result.
Here's the result
As you guys can see, there's a url coming back (url-example-1) for different keywords.
Is it possible to merge them directly from the request ? Suming all the datas (clicks, impressions, ctr...)
I know I could write a script to do it but I believe it's possible to do it natively
Thanks a lot
Related
A number of Xero accounts API samples have PHP variables which start with {
Example:
$invoices = {invoices:[{type: Invoice.TypeEnum.ACCREC, contact:{contactID:"00000000-0000-0000-000-000000000000"}, lineItems:[{ description:"Acme Tires", quantity:2.0, unitAmount:20.0, accountCode:"000", taxType:"NONE", lineAmount:40.0}], date:"2019-03-11", dueDate:"2018-12-10", reference:"Website Design", status: Invoice.StatusEnum.DRAFT}]};
I am struggling to understand how this can work. I am trying to use the API to create multiple invoices in the same call, I can do it fine in Postman so I know my code is OK.
I have tried following:
creating-an-invoice-using-oauth2-in-xero
Using the documents
But for some reason I just can't find a way to make it work.
All our SDKs and documentation is generated from our OpenAPI specs. Generating runnable code in our docs is our long term goal. In the interim, we needed to offer "some" generated docs, but the JSON payloads are not meant to be used.
We have created a sample app that demonstrates different endpoints and displays the code used to make the call.
https://github.com/XeroAPI/xero-php-oauth2-app
Here is the code you'll need to create an invoices
$result = $apiInstance->getContacts($xeroTenantId);
$contactId = $result->getContacts()[0]->getContactId();
$contact = new XeroAPI\XeroPHP\Models\Accounting\Contact;
$contact->setContactId($contactId);
$arr_invoices = [];
$invoice_1 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_1->setReference('Ref-456')
->setDueDate(new DateTime('2019-12-10'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_1);
$invoice_2 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_2->setReference('Ref-123')
->setDueDate(new DateTime('2019-12-02'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_2);
$invoices = new XeroAPI\XeroPHP\Models\Accounting\Invoices;
$invoices->setInvoices($arr_invoices);
$result = $apiInstance->createInvoices($xeroTenantId,$invoices);
I have the following problem:
I need to get a few columns of a oracle db table to display information on a .php page. To do this, I'm using a SOAP-API, which works flawlessly with any other table, only not with this one.
This is the Code I am using for all of these Queries:
$setSearchObjectsIn = new SearchObjectsInType();
$setSearchObjectsIn->sessionId = (String) $sessionId;
$setSearchObjectsIn->table = (String) 'STFCFG_DD_VALUE';
$setSearchObjectsIn->caseSensitive = (String) 'false';
$setSearchObjectsIn->limitedResult = (String) 'false';
$setSearchObjectsIn->restrictions[0]['attributeName']= (String) 'STFCFG_DD_VALUE.DDID';
$setSearchObjectsIn->restrictions[0]['restriction']['operator'] = (String) '=';
$setSearchObjectsIn->restrictions[0]['restriction']['value'] = (String) $ddid;
$setSearchObjectsIn->resultColumns[0] = (String) 'STFCFG_DD_VALUE.DD_VALUE';
$setSearchObjectsIn->resultColumns[1] = (String) 'STFCFG_DD_VALUE.CATALOG_NAME';
$setSearchObjectsIn->resultColumns[2] = (String) 'STFCFG_DD_VALUE.MSG_ID';
$client = new SoapClient((String) $instance.'/axis/services/GenericApiWS?wsdl');
$result = $client->searchObjects($setSearchObjectsIn);
And this is the Error I get with this special table:
ORA-00904: "MAN_ID": ungültiger Bezeichner
I have also tried starting this query with SoapUI, which results in the exactly same thing.
The fact, that I have nothing like "MAN_ID" in my code has me wondering, as the error looks like I would query a column named like that, which I obviously don't do. (There is also no column "MAN_ID" in the requested table, so I have no idea where this comes from)
I hope you can help me
I'd try looking for MAN_ID in the SOAP server code - the error may be what the server returns and it may be looking for that column implicitly. The error message is definitely produced by Oracle, so search the way your query gets there and if possible, see what query gets executed.
I have integrated Yelp reviews into my directory site with each venue that has a Yelp ID returning the number of reviews and overall score.
Following a successful MySQL query for all venue details, I output the results of the database formatted for the user. The Yelp element is:
while ($searchresults = mysql_fetch_array($sql_result)) {
if ($yelpID = $searchresults['yelpID']) {
require('yelp.php');
if ( $numreviews > 0 ) {
$yelp = '<img src="'.$ratingimg.'" border="0" /> Read '.$numreviews.' reviews on <img src="graphics/yelp_logo_50x25.png" border="0" /><br />';
} else {
$yelp = '';
}
} //END if ($yelpID = $searchresults['yelpID']) {
} //END while ($searchresults = mysql_fetch_array($sql_result)) {
The yelp.php file returns:
$yrating = $result->rating;
$numreviews = $result->review_count;
$ratingimg = $result->rating_img_url;
$url = $result->url;
If a venue has a Yelp ID and one or more reviews then the output displays correctly, but if the venue has no Yelp ID or zero reviews then it displays the Yelp review number of the previous venue.
I've checked the $numreviews variable type and it's an integer.
So far I've tried multiple variations of the "if ( $numreviews > 0 )" statement such as testing it against >=1, !$numreviews etc., also converting the integer to a string and comparing it against other strings.
There are no errors and printing all of the variables returned gives the correct number of reviews for each property with venues having no ID or no reviews returning nothing (as opposed to zero). I've also compared it directly against $result->review_count with the same problem.
Is there a better way to make the comparison or better format of variable to work with to get the correct result?
EDIT:
The statement if ($yelpID = $searchresults['yelpID']) { is not operating as it should. It is identical to other statements in the file, validating row contents which work correctly for their given variable, e.g. $fbID = $searchresults['fbID'] etc.
When I changed require('yelp.php'); to require_once('yelp.php'); all of the venue outputs changed to showing only the first iterated result. Looking through the venues outputted, the error occurs on the first venue after a successful result which makes me think there is a pervasive piece of code in the yelp.php file, causing if ($yelpID = $searchresults['yelpID']) { to be ignored until a positive result is found (a yelpID in the db), i.e. each venue is correctly displayed with a yelp number of reviews until a blank venue is encountered. The preceding venues' number of reviews is then displayed and this continues for each blank venue until a venue is found with a yelpID when it shows the correct number again. The error reoccurs on the next venue output with no yelpID and so on.
Sample erroneous output: (line 1 is var_dump)
string(23) "bayview-hotel-bushmills"
Bayview Hotel
Read 3 reviews on yelp
Benedicts
Read 3 reviews on yelp (note no var_dump output, this link contains the url for the Bayview Hotel entry above)
string(31) "bushmills-inn-hotel-bushmills-2"
Bushmills Inn Hotel
Read 7 reviews on yelp
I suspect this would be a new question rather than clutter/confuse this one further?
END OF EDIT
Note: I'm aware of the need to upgrade to mysqli but I have thousands of lines of legacy code to update. For now I'm working on functionality before reviewing the code for best practice.
Since the yelp.php is sort of a blackbox; the best explanation for this behavior would be that it only set's those variables if it finds a match. Updating your code to this should fix that:
unset($yrating, $numreviews, $ratingimg, $url);
require('yelp.php');
I also noticed this peculiar if-statement, do you realize that's an assignment or is this a copy/paste error? If you want to test (that's what if is for)
if ($yelpID == $searchresults['yelpID']) {
I'm trying to get FullCalendar working on my Codeigniter app, but coming across a problem with the events showing as all day from my JSON feed.
I've found that setting "allDay":false fixes the problem (tested with a static json file) but when i store that value in a mysql DB, then return the data and run the JSON encode, it converts the False into a string, which cause the event to show as all day!
Does anybody know how i can store true or false in my DB (i'm currently storing as text) and return it to my json feed without it being a string? I've tried casting and converting but can't get anything to work!
Examples of my model/controller/json feed below;
Thanks in advance;
Model function
function show_installs()
{
return $this->db->query(
"SELECT id, client_name as title, start, end, concat('/planner/view_install/',id) as url
FROM installs WHERE completed != 2"
)->result();
}
Controller function
function json_installs()
{
$this->load->model('installs_model');
$data = array();
if($query = $this->installs_model->show_installs())
{
$data = $query;
}
$json = json_encode($data);
echo $json;
}
JSON Feed (That doesnt work because of the " around false)
[
{
"id":"18",
"title":"John",
"allDay":"false",
"start":1339585200,
"end":1339592400,
"url":"\/planner\/view_install\/18"
},
{
"id":"19",
"title":"Mike",
"allDay":"false",
"start":"1339585200",
"end":"1339592400",
"url":"\/planner\/view_install\/19"
}
]
Any help would be really appreciated - i just need to get those bloomin quote marks off from false/true and it would work perfectly!
Thanks
Why don't you change the column type in your DB to be boolean instead of text? You could also parse your $json object to convert all booleans_as_text to booleans before you set it in the calendar - quick googling found me this:
for(var i=0; i<$json.length; i++)
$json[i]=/^true$/i.test($json[i]);
You could also set the allDayDefault to false to avoid set allday: false in each event.
Okay normally I'm all fine about the facebook API but I'm having a problem which just keeps me wondering. (I think it's a bug (Check ticket http://bugs.developers.facebook.net/show_bug.cgi?id=13694) but I wanted to throw it here if somebody has an idea).
I'm usng the facebook PHP library to count all attendees for a specific event
$attending = $facebook->api('/'.$fbparams['eventId'].'/attending');
this works without a problem it correctly returns an array with all attendees...
now heres the problem:
This event has about 18.000 attendees right now.
The api call returns a max number of 992 attendees (and not 18000 as it should).
I tried
$attending = $facebook->api('/'.$fbparams['eventId'].'/attending?limit=20000');
for testing but it doesn't change anything.
So my actual question is:
If I can't get it to work by using the graph api what would be a good alternative? (Parsing the html of the event page maybe?) Right now I'm changing the value by hand every few hours which is tedious and unnecessary.
Actually there are two parameters, limit and offset. I think that you will have to play with both and continue making calls until one returns less than the max. limit.
Something like this, but in a recursive approach (I'm writting pseudo-code):
offset = 0;
maxLimit = 992;
totalAttendees = count(result)
if (totalAttendees >= maxLimit)
{
// do your stuff with each attendee
offset += totalAttendees;
// make a new call with the updated offset
// and check again
}
I've searched a lot and this is how I fixed it:
The requested URL should look something like this.
Here is where you can test it and here is the code I used:
function events_get_facebook_data($event_id) {
if (!$event_id) {
return false;
}
$token = klicango_friends_facebook_token();
if ($token) {
$parameters['access_token'] = $token;
$parameters['fields']= 'attending_count,invited_count';
$graph_url = url('https://graph.facebook.com/v2.2/' . $event_id , array('absolute' => TRUE, 'query' => $parameters));
$graph_result = drupal_http_request($graph_url, array(), 'GET');
if(is_object($graph_result) && !empty($graph_result->data)) {
$data = json_decode($graph_result->data);
$going = $data->attending_count;
$invited = $data->invited_count;
return array('going' => $going, 'invited' => $invited);
}
return false;
}
return false;
}
Try
SELECT eid , attending_count, unsure_count,all_members_count FROM event WHERE eid ="event"