I guess I'm missing something basic here, but when I try out the example from here (adapted to my context):
<?php
$piwikTracker = new PiwikTracker( $idSite = {$IDSITE} );
// Specify an API token with at least Admin permission, so the Visitor IP address can be recorded
// Learn more about token_auth: https://piwik.org/faq/general/faq_114/
$piwikTracker->setTokenAuth('my_token_auth_value_here');
// You can manually set the visitor details (resolution, time, plugins, etc.)
// See all other ->set* functions available in the PiwikTracker.php file
$piwikTracker->setResolution(1600, 1400);
// Sends Tracker request via http
$piwikTracker->doTrackPageView('Document title of current page view');
// You can also track Goal conversions
$result = $piwikTracker->doTrackGoal($idGoal = 1, $revenue = 42);
?>
the $result variable contains
GIF89a�����������!�����,�������D�;
which I'm told is a small tracking GIF. But why on earth would the API return a tracking GIF? Shouldn't it rather be a status result about success/failure?
Related
I found following thread at : https://issuetracker.google.com/issues/133299031#comment14
Hello, In-app update priority of the release can be set using the Play Developer Publishing API's Edits methods. There is a new 'inAppUpdatePriority' field under Edits.tracks.releases. The documentation does not mention the new field yet but you should still be able to set it. In-app update priority can not be set from the Google Play Console at the moment.
I am using google-api-php-client with Service Account authentication, I would like to ask how to set 'inAppUpdatePriority' using google-api-php-client I have tried following in my PHP code.
$publisher->edits_tracks->update(self::PACKAGE_NAME, self::EDIT_ID, 'production', new \Google_Service_AndroidPublisher_Track);
After hours of testing with Google API PHP Client, I managed to edit the inAppUpdatePriority field, with Laravel, this way:
try {
$packageName = "your.package.name";
$versionCode = "version_code_as_string"; //example "50"
$client = new \Google\Client();
//you need to setup your own Service Account or other API access methods
$client->setAuthConfig("path/to/your/json/file");
$client->addScope(AndroidPublisher::ANDROIDPUBLISHER);
$service = new \Google\Service\AndroidPublisher($client);
//create new edit
$appEdit = $service->edits->insert($packageName, new \Google\Service\AndroidPublisher\AppEdit());
//uncomment if you want to get hold of available tracks
// $tracksResponse = $service->edits_tracks->listEditsTracks($packageName, $appEdit->id);
// dd($tracksResponse);
$trackRelease = new \Google\Service\AndroidPublisher\TrackRelease();
$trackRelease->versionCodes = [$versionCode];
//set desired update priority
$trackRelease->inAppUpdatePriority = 5;
$trackRelease->status = "completed";
$postBody = new \Google\Service\AndroidPublisher\Track();
$postBody->setReleases([$trackRelease]);
//desired track to update. One of the followings: production,beta,alpha,internal
$track = "production";
$update = $service->edits_tracks->update($packageName, $appEdit->id, $track, $postBody);
//commit changes to Google Play API
$service->edits->commit($packageName, $appEdit->id);
// dd($update);
} catch (Exception $ex) {
if ($ex->getCode() == 404) {
//this catches if some info is wrong (tested with a version code that has not been upload to Google Play Console)
}
}
Notes:
You should note that for this to work (without implementing your propre way of uploading app via Google Play API), you need to first upload your app via Google Play Console to your desired track, then click Save, then Review release and */!\DON'T CLICK Rollout release/!*, then run the above mentioned code which will Commit (Rollout) the changes (if you try to rollout release after running the above code, you will get an error that you can ignore).
Any changes to inAppUpdatePriority won't be applied if your release is already rolled out.
You should have already published at least one release in the desired track before you can use this (tested with Internal testing only)
What I'm trying to currently do is fetch Campaign statistics such as Clicks, Impressions, CTR, Average CPC and etc for a particular campaign. Unfortunately, I can't find how to do it via the AdWords API.
What I've found up till now is that,
Maybe, in an earlier version of the CampaignService, we were able to obtain stats by doing something like $campaign->campaignStats. Unluckily, I'm using V201506 and in it there is no campaignStats object/variable.
I probably can get these stats using the 'CAMPAIGN_PERFORMANCE_REPORT' but it needs to be downloaded and I don't want to download the report. I just want an array or something similar returned so that I can process it. Also, I don't want to give any time frame, I just want all time stats to be returned for that campaign. Is it even possible?
If any one could help me out, I would really appreciate it. Kind of been stuck here for a few hours, skimmed through the whole AdWords API documentation but couldn't understand what would be the best and easy approach to this.
Now, Adwords API allowing stats only By reporting service.
And stats can be get using two methods.
1) By using reporting service as described
here
2) You can use Adwords Query Language. See
this
i don't know if you still need this but the API V201806 I found a solution. In this version of API exist the function getAsString() which returns the data in String and not download file, I request data in format XML and in PHP transform the response into a XML Object.
This is code I used:
class DownloadCriteriaReportWithAwql {
public static function runExample(AdWordsSession $session, $reportFormat){
// Create report query to get the data for last 7 days.
$query = (new ReportQueryBuilder())
->select([
'CampaignId',
'AdGroupId',
'Id',
'Criteria',
'CriteriaType',
'Impressions',
'Clicks',
'Cost',
'Conversions'
])
->from(ReportDefinitionReportType::CRITERIA_PERFORMANCE_REPORT)
->where('Status')->in(['ENABLED'])
->duringDateRange(ReportDefinitionDateRangeType::LAST_7_DAYS)
->build();
// Download report as a string.
$reportDownloader = new ReportDownloader($session);
// Optional: If you need to adjust report settings just for this one
// request, you can create and supply the settings override here.
// Otherwise, default values from the configuration
// file (adsapi_php.ini) are used.
$reportSettingsOverride = (new ReportSettingsBuilder())->includeZeroImpressions(false)->build();
$reportDownloadResult = $reportDownloader->downloadReportWithAwql(
sprintf('%s', $query),
$reportFormat,
$reportSettingsOverride
);
//print "Report was downloaded and printed below:\n";
$datos = $reportDownloadResult->getAsString();
return ($datos);
}
public static function main(){
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
// See: AdWordsSessionBuilder for setting a client customer ID that is
// different from that specified in your adsapi_php.ini file.
// Construct an API session configured from a properties file and the
// OAuth2 credentials above.
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();
$string = self::runExample($session, DownloadFormat::XML);
$xml = new \SimpleXMLElement($string);
return $xml;}}
The question was asked in 2015, since then they renamed the API to Google Ads API. The current version is V6 where getting clicks, CTR, CPC and other metrics is relatively simple.
The documentation here states:
This page shows all metrics and segments that can be put in the same SELECT clause as the fields of campaign
Based on that the AWQL for getting campaign together with clicks will look like this (tested):
$query = "SELECT campaign.id, campaign.name, campaign.status, metrics.clicks FROM campaign ORDER BY campaign.name"
Example in PHP how to iterate through results:
$stream = $googleAdsServiceClient->searchStream($customerId, $query);
foreach ($stream->iterateAllElements() as $googleAdsRow) {
/** #var GoogleAdsRow $googleAdsRow */
$data['campaigns'][] = [
'id' => $googleAdsRow->getCampaign()->getId(),
'clicks' => $googleAdsRow->getMetrics()->getClicks(),
];
}
I've seen some Twilio experts answer other questions on here before about using Twilio's service so I'm hoping this catches the eye of one of them. :)
Essentially, I need to create a system whereby two callers can connect (a sales agent and a customer) with the capability for a manager to listen in to a live call. From my research into Twilio's API I believe the only way to accomplish this is to have each call be a conference call, and allow the managers to join that call in 'muted' mode, thereby only allowing them to listen to the call between the agent and customer.
I'm developing in PHP and I believe I have 90% of the puzzle solved, however I'm have trouble with one small detail.
I'll lay out the logical flow below so you can see what I'm trying to do:
1) Customer or Sales Agent dials a number.
2) Conference room gets dynamically generated and the person dialing out is placed into that room.
3) I use the REST API to make a call request to the other number, then direct them into the conference room that was already generated with the first person waiting.
I have steps 1 and 2 completed and working fine, step 3 is where the problem occurs. When I use the API to generate the second call to bring the other person into the conference room the request goes through the same application that was used to generate the first call, thereby creating an infinite loop of making new calls and generating new rooms. I have attached my code below to help explain the issue.
public function index()
{
if (isset($_REQUEST['PhoneNumber'])) {
// The agent is making a call (outgoing)
$data['callerId'] = $this->users->getPhoneNumber($_REQUEST['Caller']);
$userIdExplode = explode(':', $_REQUEST['Caller']);
$data['userId'] = $userIdExplode[1];
$callTarget = $this->security->xss_clean($_REQUEST['PhoneNumber']);
$data['numberOrClient'] = "<Number>" . $callTarget . "</Number>";
$data['phoneIsOnline'] = $this->users->isPhoneOnline($data['userId']);
// Call log information
$data['ani'] = $data['callerId'];
$data['dnis'] = $callTarget;
} elseif (isset($_REQUEST['To'])) {
// The agent is receiving a call (incoming)
$callTarget = $this->security->xss_clean($_REQUEST['To']);
$data['userId'] = $this->users->getIdByPhoneNumber($callTarget);
$data['numberOrClient'] = "<Client>" . $data['userId'] . "</Client>";
$data['phoneIsOnline'] = $this->users->isPhoneOnline($data['userId']);
// Call log information
$data['ani'] = $_REQUEST['From'];
$data['dnis'] = $_REQUEST['To'];
}
// Log the new call and receive it's log ID
$data['callLogId'] = $this->call->logNewCall($data['ani'], $data['dnis'], $data['userId']);
// Load the TWIML (Twilio XML) to bring the caller into a conference room
$this->load->view('twilio/connections_twiml', $data);
// Bring the destination number into the same conference room as the origin number
$this->dialToConference($data['ani'], $data['dnis'], $data['callLogId']);
}
public function dialToConference($caller, $callee, $confNum)
{
// Twilio capability library (capable of incoming and outgoing calls)
include APPPATH . 'libraries/twilio/Services/Twilio.php';
// Twilio account codes required for the client
$accountSid = $this->config->item('twilio_accountSid');
$authToken = $this->config->item('twilio_authToken');
$client = new Services_Twilio($accountSid, $authToken);
$call = $client->account->calls->create(
$caller,
$callee,
BASE_URL . 'twilio/twilio_connections/loadConferenceTwiml?conferenceId=' . $confNum
);
}
For testing purposes, I'd like to get my own full profile datas from LinkedIn API.
So far my code looks like this :
// Fill the keys and secrets you retrieved after registering your app
$oauth = new OAuth("APIKEY", "SECRETKEY");
$oauth->setToken("Token OAuth", "Secret User OAuth");
$oauth->disableSSLChecks();
$params = array();
$headers = array();
$method = OAUTH_HTTP_METHOD_GET;
// Specify LinkedIn API endpoint to retrieve your own profile
$url = "https://api.linkedin.com/v1/people/~:(first-name,last-name,headline,location:(name),skills:(name),educations:(id,school-name,field-of-study))?format=json";
// By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call
// $url = "https://api.linkedin.com/v1/people/~?format=json";
// Make call to LinkedIn to retrieve your own profile
$oauth->fetch($url, $params, $method, $headers);
$oProfile = json_decode($oauth->getLastResponse());
var_dump($oProfile);
Although I am getting basic profile informations (firstName,headline etc...) but when it comes to full profile informations I get an object with '...' as value everytime, although the informations exist.
I have r_fullprofile ticked in my LinkedIn app interface, so I don't know what I have to do to get these values.
I tried your query with my own account. It looks you issue is with the skills field.
You can see in the LinkedIn API documentation that skills are made up of a skill, and each skill has a name. If you only want the name returned the proper way to ask for it is
skills:(skill:(name)), whereas your request asks for skills:(name).
Here is an updated request for you:
GET https://api.linkedin.com/v1/people/~:(first-name,last-name,headline,location:(name),skills:(skill:(name)),educations:(id,school-name,field-of-study))?format=json
I'm trying to use Facebook's API code to have a user attend an event, but it's not working. I can run the post comment on my browser window but as a php script it's not working
$fields = array('access_token'=>$access_token);
$result = HTTP_POST("https://graph.facebook.com/4XXXXX663/invited?access_token=$access_token",// URL to query
$fields, // POST fields; associative array
USER_AGENT, // user-agent value
"", // cookie storage and retrieval
"", // proxy; type:ip:port[:user:pass]; supported types: http, socks5
true, // return the data or not
false, // include headers in the return data
"", // set value for REFERER header
true, // automatically follow "redirects" ("Location" header)
false); // enable or disable multipart post (if uploading, set to true)
You're passing access_token with the URL as well as the POST data.
Remove the ?access_token=$access_token part in your URL and try again.
Also it would be good if you could post the error you're getting, So we can see what's the actual issue and also make sure you post that HTTP_POST function so we can know if the cURL settings are correct (I'm assuming this function is using cURL).
EDIT 1: Removed, Just realized you're trying to attend an event and not invite.
Edit 2: You need to ask your users to give rsvp_event permissions in order to make them attend your event via your App. You also need to make an HTTP POST to EVENT_ID/attending (This is for attending the event) and not to EVENT_ID/invited (This is for inviting users/friends to your event).