i am trying to get user activity via aweber rest api using thier aweber php library.
code:
$all_subscribers = $account->findSubscribers($params);
foreach ($all_subscribers as $sub) {
echo "<p><strong>Name:</strong> {$sub->name}</p>";
echo "<p><strong>Email:...;
foreach ($sub->getActivity() as $event) {
echo "<p>{$event->type}: {$event->event_time}</p>";
}
}
i am able to get the details such as event type and event timing but i also need to fetch title and the url of the message on which the events were happened.
i also tried $event->self_link but it was no help.
Here is the data return by getActivity() method
[data] => Array
(
[event_time] => 2017-04-30 07:05:00-04:00
[resource_type_link] => https://api.aweber.com/1.0/#open
[http_etag] => "28eb617e4d24407e49b14a9402608f423da2f4a7-ca5feee2b7fbb6febfca8af5541541ea960aaedb"
[subscriber_link] => https://api.aweber.com/1.0/accounts/1011749/lists/4120909/subscribers/59065294
[self_link] => https://api.aweber.com/1.0/accounts/1011749/lists/4120909/campaigns/f28501689/messages/40127/opens/15096
[type] => open
[id] => 15096
)
Related
I am targeting to load Google Jobs search result in my custom website.
So for that I created account on google and enable Google Talent API. After enable billing on google cloud API account, they allow me request to this API using API Key and Service account credentials.
I am currently using PHP with the use of api-client-php library.
For that I have download .json file for credential (client_secret.json) from google Console Talent Platform.
Here is my sample code in PHP.
require 'vendor/autoload.php';
// Instantiate the client
$client = new Google_Client();
$api_key = 'AdsadsIzaSyBYAMxEPPasdadadw5VHITCdREQW7WYeIGs8jRlUYqlzLM';
$client->setDeveloperKey($api_key);
$client->setAuthConfig(getcwd() . '/client_secret.json');
$client->setScopes(array(
'https://www.googleapis.com/auth/jobs',
'https://www.googleapis.com/auth/cloud-platform'
));
$jobs = new Google_Service_JobService($client);
$location='USA';
// Set the Metadata
$requestMetadata = new Google_Service_JobService_RequestMetadata();
$requestMetadata->setUserId('000aaaa');
$requestMetadata->setSessionId('000aaaa-1212-21212');
$requestMetadata->setDomain('www.google.com');
$jobQuery = new Google_Service_JobService_JobQuery();
$keyword='software OR java';
$jobQuery->setQuery($keyword);
// Search Job Request
$searchRequest = new Google_Service_JobService_SearchJobsRequest();
$searchRequest->setRequestMetadata($requestMetadata);
$searchRequest->setQuery($jobQuery);
$searchRequest->setMode('JOB_SEARCH');
$jobService = new Google_Service_JobService($client);
$response = $jobService->jobs->search($searchRequest);
echo "<pre>";
print_r($response);
print_r($response->matchingJobs);
While sending this request, We are getting matchingjobs blank array but $response have some object array. which is something like not output but just request information.
here is the response which we are getting so far using Talent Search API.
Google_Service_JobService_SearchJobsResponse Object
(
[collection_key:protected] => matchingJobs
[appliedCommuteFilterType:protected] => Google_Service_JobService_CommutePreference
[appliedCommuteFilterDataType:protected] =>
[appliedJobLocationFiltersType:protected] => Google_Service_JobService_JobLocation
[appliedJobLocationFiltersDataType:protected] => array
[estimatedTotalSize] =>
[histogramResultsType:protected] => Google_Service_JobService_HistogramResults
[histogramResultsDataType:protected] =>
[jobView] =>
[matchingJobsType:protected] => Google_Service_JobService_MatchingJob
[matchingJobsDataType:protected] => array
[metadataType:protected] => Google_Service_JobService_ResponseMetadata
[metadataDataType:protected] =>
[nextPageToken] =>
[numJobsFromBroadenedQuery] => 0
[spellResultType:protected] => Google_Service_JobService_SpellingCorrection
[spellResultDataType:protected] =>
[totalSize] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
[metadata] => Google_Service_JobService_ResponseMetadata Object
(
[collection_key:protected] => experimentIdList
[experimentIdList] => Array
(
[0] => 11300310
[1] => 11300342
)
[mode] => JOB_SEARCH
[requestId] => f5cacd36-db29-4d65-851f-34a97c98af79:APAb7IRQAVop4QZ6rC2OlKjcEARRJQHI8w==
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
)
Array
(
)
I am confuse here, Talent API can search and load google Jobs on our website OR we need to create company and jobs and they just provide Advanced search filter using AI and ML ?
Lets if they provide google Jobs on our website then what is wrong in my code ?
Please suggest me.
Google's Talent API only works with data you provide it, so yes, you should create companies and jobs and then apply the searches to those jobs.
The second step in the checklist they've published for launching apps that use this API is Index companies and jobs, with clear mentions of these being from your own database:
Create at least one Company. We recommend creating Company objects for
all companies in your database with open jobs.
Create Jobs for your Companies. We recommend creating Job objects for
all open jobs in your database.
Additional proof that supports this disappointing reality is an article published by Ivan Davchev after the Google conference where this API was announced:
What Is Google Jobs API?
It is a turn-key solution to searching your jobs. Like most cloud-based search > solutions, you need to feed it documents (jobs) which it indexes and makes searchable.
[...]
It is not an aggregator and does not offer “all jobs in the world” out of the box. > So you can’t build an Indeed competitor in an afternoon with this API. It only searches > what you provide it, which is why it makes sense for job boards and applicant tracking > systems (ATS) to use it — jobs are posted on and managed by those systems.
I have a sandbox API account and I am not able to fetch Instagram posts comments data. I try to use
$comments = $instagram->getMediaComments($media_id);
but I am getting the following error:
stdClass Object
(
[meta] => stdClass Object
(
[code] => 400
[error_type] => OAuthAccessTokenException
[error_message] => The access_token provided is invalid.
)
)
Update: Key and secret are correct because all other info I am getting, like comments count, is correct.
Now I have changed
return $this->_makeCall('media/' . $id . '/comments', true);
and added scope
private $_scopes = array('basic', 'likes', 'comments',
'relationships', 'public_content', 'follower_list');
now the authentication error is gone but the comment data is still blank.
I have implemented the Google API in PHP as a service and using the Google_Service_ServicePeople() to add a contact. That works and I am getting back a proper result as a paople object. In addition when I call the people_connections->listPeopleConnections method I am getting back the contacts that I have created in my tests. However, when I go to contacts.google.com no contact will be shown.
Maybe it is a missunderstanding from my site, but I thought that based on the appsettings on my account, the new contacts will be created (added) to my account, won't they?
$client = new Google_Client();
$client->setApplicationName ('VABS-CONTACT-TEST');
$client->setAuthConfig($_SERVER['DOCUMENT_ROOT'].'/includes/classes/Google/auth.json');
$client->addScope (Google_Service_Peopleservice::CONTACTS);
$peopleService = new Google_Service_PeopleService($client);
$person = new Google_Service_PeopleService_Person();
$name = new Google_Service_People_Name();
$name->setDisplayName ('FirstName LastName');
$name->setFamilyName ('LastName');
$name->setGivenName('FirstName');
$email = new Google_Service_People_EmailAddress();
$email->value = 'xxx#xxx.xx';
$person->setNames ($name);
$person->setEmailAddresses ($email);
$result = $peopleService->people->createContact ($person);
The response looks like:
Google_Service_PeopleService_Person Object
(
[collection_key:protected] => userDefined
[addressesType:protected] => Google_Service_PeopleService_Address
[addressesDataType:protected] => array
[ageRange] =>
[ageRangesType:protected] => Google_Service_PeopleService_AgeRangeType
[ageRangesDataType:protected] => array
[biographiesType:protected] => Google_Service_PeopleService_Biography
[biographiesDataType:protected] => array
[birthdaysType:protected] => Google_Service_PeopleService_Birthday
[birthdaysDataType:protected] => array
[braggingRightsType:protected] => Google_Service_PeopleService_BraggingRights
[braggingRightsDataType:protected] => array
[coverPhotosType:protected] => Google_Service_PeopleService_CoverPhoto
[coverPhotosDataType:protected] => array
[emailAddressesType:protected] => Google_Service_PeopleService_EmailAddress
[emailAddressesDataType:protected] => array
[etag] => %Eh8BAgMEBQYHCAkKCwwNDg8QERITFBUWFzUZNDciJScuGgwBAgMEBQYHCAkKCwwiDFFrVXd2SnRpTFZZPQ==
[eventsType:protected] => Google_Service_PeopleService_Event
[eventsDataType:protected] => array
[gendersType:protected] => Google_Service_PeopleService_Gender
.
.
.
.
(
)
[modelData:protected] => Array
(
[metadata] => Array
(
[sources] => Array
(
[0] => Array
(
[type] => CONTACT
[id] => 494c65970e1a12eb
[etag] => #QkUwvJtiLVY=
[updateTime] => 2018-04-04T13:58:27.710001Z
)
...
Using the
$peopleService->people_connections->listPeopleConnections('people/me',$options)
lists all the created contacts as expected.
But on my contacts.google.com page no contact will be shown. I am logged in as the same user I have created and granted access to the API.
Any ideas, hwy the contacts won't be shonw on contacts.google.com?
Many thanks!
After several tries it wasn't possible for me to get it solved. Therefore I have tried it now via the RapidWeb Solution. Now it is working and "the setup" with a guide - even though it tooks also 3 steps of getting the right account in place - is simple.
The main problem I had is to understand the logfic of OAuth2 and their possibilities to setup the correct OAuth2 Client.
In my case I needed to setup a Native Client (just choose "Other" as ApplicationType on the second screen in the Google API Console after creating a new OAuth2 ClientId)
Anyway. Many thanks for all who tried to help me! Much appreciated!
Cheers!
My question relates to pulling data from a remote source and saving it to a local database. With the saveAll(), the parent data gets saved correctly, but not the child data.
protected function _saveLocal($_rekeyedData) {
//Set the invoice header and line items models
if (!isset($this->LocalHeader)) {
$this->loadModel('LocalHeader');
$this->LocalHeader->create();
// $this->LocalHeader->set($_rekeyedData);
if (!isset($this->LocalDetail)) {
$this->loadModel('LocalDetail');
$this->LocalDetail->create();
}
}
if ($this->LocalHeader->saveAll($_rekeyedData, array('validate' => 'first'))) {
$this->Session->setFlash('Your data has been saved.');
} else {
$this->Session->setFlash('Data load failed.');
}
debug( $this->LocalDetail->invalidFields() );
}
In this function, I load the models, then attempt to saveAll(). A sample record looks like this:
[1] => Array
(
[LocalHeader] => Array
(
[SOPNUMBE] => CR014076
[DUEDATE] => 2012-04-10 00:00:00
[DOCDATE] => 2012-04-10 00:00:00
[DOCAMNT] => 12000.00000
[SUBTOTAL] => 12000.00000
)
[LocalDetail] => Array
(
[0] => Array
(
[ITEMNMBR] => BASIC SERVICE
[QUANTITY] => 1.00000
[UOFM] => EA
[UNITPRCE] => 12000.00000
[TAXAMNT] => .00000
[CONTSTARTDTE] => 1900-01-01 00:00:00
[CONTENDDTE] => 1900-01-01 00:00:00
[SOPNUMBE] => CR014076
)
)
)
All that gets saved is the LocalHeader record. My hunch is that it has something to do with the array('validate' => 'first'). I think I need to do something separate like validateMany when using saveAll(), but I can't remember where I saw something like that or if I just made it up.
I've read many of the related questions in SO, but none of the offered solutions worked for me.
Any help is appreciated. Please feel free to ask if you have any questions.
EDIT:
This is the header model and this is the detail model.
I think the issue is that neither of those records exists yet. According to the docs
If neither of the associated model records exists in the system yet
(for example, you want to save a new User and their related Profile
records at the same time), you’ll need to first save the primary, or
parent model.
You can read more here with an example.
I'm developing my first Facebook app in PHP and was wondering if the page on Facebook that it's being viewed in can be detected by the app. I'm planning on displaying the app on several different pages and want the app to display something different for each of the pages. This way I would only the need the user to accept the permissions for one central app instead of several different ones.
Yes. There is signed_request (POST), with Page ID... You cannot get entire URL because request is going trough Facebook proxy. Here is the way how you can do it, later just serve content based on Page ID...
$signed_request = $_POST['signed_request'];
$response = Facebook::parse($signed_request);
$page_id = $response['page']['id'];
(this is just the part of my class)
class Facebook {
// Facebook signed request parser
public static function parse($signed)
{
list($encoded, $payload) = explode('.', $signed, 2);
$sig = Facebook::base64_url_decode($encoded);
$data = json_decode(Facebook::base64_url_decode($payload), true);
if(strtoupper($data['algorithm']) !== 'HMAC-SHA256'){
error_log('Unknown algorithm. Expected HMAC-SHA256');
return false;
}
return $data;
}
// Base64 decode for Facebook
private static function base64_url_decode($input)
{
return base64_decode(strtr($input, '-_', '+/'));
}
}
edit:
Like you have said, you need to authorize app only once per user, and you will be able to use it across all pages (I have hundreds of them). This is output of signed_request when user is "connected" to app.
Array
(
[algorithm] => HMAC-SHA256
[expires] => 0
[issued_at] => 1311062412
[oauth_token] =>
[page] => Array
(
[id] => 149715315100385
[liked] => 1
[admin] => 1
)
[user] => Array
(
[country] => ba
[locale] => en_US
[age] => Array
(
[min] => 21
)
)
[user_id] => 1368368917
)
You can see page->id, a user_id, also you will get token for accessing user info (for those you have permission).
You set this location in the developer application when you create your first app. Go to facebook.com/developers and create a new app and you will be able to set the location of your canvas application, which is then loaded in app.facebook.com/YOUR_APP_NAME.