I've an iphone app and a web app(in php ), i want to synchronize contacts in iphone app with database records.(from both device and web app ie. user can add/update/delete contacts from device or web app and both database will sync.)
Thanks
Use php-addressbook.sf.net, it includes a Exchange Interface to Sync your iPhone.
your question is not clear anyway I will give you some ideas
ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
for ( int i = 0; i < nPeople; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex( allPeople, i );}
here the link for editing contacts and managing contacts
http://zcentric.com/2008/09/19/access-the-address-book/
https://developer.apple.com/library/ios/#samplecode/QuickContacts/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009475
Related
i'm using onesignal to push notifications to users of an android app, all subscribed users have their email as an external_user_id.
I need display all subscribed devices to the user (in case he would want to unsubscribe remotely to the app). At the moment this can be done with rest api (https://documentation.onesignal.com/reference/view-devices) however i would need to filter the resulting object myself for the desired devices and there is a limit to how much data can return from the endpoint.
I have not found a filter for this endpoint in the documentation so i ask if there is another way to get the desired data.
I have used this API to get onesignal devices "https://onesignal.com/api/v1/players?app_id=" . $app_id and with the following code you can limit returned data:
$limit = 50;
$offset = 0;
$query = [
'limit' => max(1, min(50, filter_var($limit, FILTER_VALIDATE_INT))),
'offset' => max(0, filter_var($offset, FILTER_VALIDATE_INT)),
'app_id' => $app_id,
];
$response = file_get_contents("https://onesignal.com/api/v1/notifications?view_notification_type=api&".http_build_query($query), false, $context);
So we have a website where Employers can log in and add new employees they just hired. When you hit 'Submit' on the form asking for the employees info, a unique link is created that if they click on, it will take them to a page to view the handbook (Onboarding) and electronically sign for it. We recently have a new Employer who wanted to see if we could add his current 300 employees into the site and have each one view and sign the handbook. I able to dumb all 300 employees into the database with MySQL but the issue now is that a Unique Link was never created for all of them because the 'Submit' button was never pushed for each one.
What do you guys think would be the best method to tackle this? Im not really sure how the Unique Links are created but I think I found the code that creates it. I was thinking of just creating a button that would create the link but I would have to tell it to do it for each of the 300 employees. I just cant seem to think of a better way.
<?php
ob_start();
//-------------------PAGE SETUP------------------------------------------------------
// Connect to the database
include( "db/connect.php" );
include( "db/dbFunctions.php" );
//-----------------------------------------------------------------------------------
//Restrict Users who do not have the Onboarding service
if (!hasService($USERID,'Onboarding')) {header( 'Location: home.php' ,true,301) ;}
//Check to see if the user has access to this functionality
checkAccessToFunctionality($USERID,$USERTYPE,'ADDEMPLOYEE',true);
$client = getClient($_POST['clientid'],$USERID);
$clientID = $client->id;
$locationID = $_POST['locationid'];
$templateID = $_POST['templateid'];
//Update the data fields
if ($clientID)
{
//Create the account and add data
$newuserID = createOnboardingEmployee();
setData($newuserID,'tblonboardingemployees','locationid',$_POST['locationid']);
setData($newuserID,'tblonboardingemployees','firstname',$_POST['firstname']);
setData($newuserID,'tblonboardingemployees','lastname',$_POST['lastname']);
setData($newuserID,'tblonboardingemployees','middleinitial',$_POST['middleinitial']);
setData($newuserID,'tblonboardingemployees','ssn',$_POST['ssn']);
setData($newuserID,'tblonboardingemployees','phone',$_POST['phone']);
setData($newuserID,'tblonboardingemployees','hiredate',$_POST['dateofhire_year'].'-'.$_POST['dateofhire_month'].'-'.$_POST['dateofhire_day']);
setData($newuserID,'tblonboardingemployees','startdate',$_POST['startdate_year'].'-'.$_POST['startdate_month'].'-'.$_POST['startdate_day']);
setData($newuserID,'tblonboardingemployees','hourlyrate',$_POST['hourlyrate']);
setData($newuserID,'tblonboardingemployees','addedby',$USERID);
setData($newuserID,'tblonboardingemployees','customfield1',$_POST['customfield1']);
setData($newuserID,'tblonboardingemployees','customfield2',$_POST['customfield2']);
setData($newuserID,'tblonboardingemployees','customfield3',$_POST['customfield3']);
setData($newuserID,'tblonboardingemployees','customfield4',$_POST['customfield4']);
setData($newuserID,'tblonboardingemployees','customfield5',$_POST['customfield5']);
if (isset($_POST['noemail']))
{
setData($newuserID,'tblonboardingemployees','noemail','1');
}
else{
setData($newuserID,'tblonboardingemployees','emailaddress',$_POST['email']);
}
//Set the employee's onboarding link
setData($newuserID,'tblonboardingemployees','onboardinglink',$newuserID . '-' . GUID());
//Set the onboarding template to use for the employee
assignOnboardingTemplateToEmployee($templateID,$locationID,$newuserID,$USERID);
//Send the onboarding link to the user
sendOnboardingIntroEmail($USERID,$newuserID,$templateID);
//auditaction($USERID,'USER',$newuserID,'User Added','UserType='.$_POST['usertype'],null);
//Assign permission to all client data and locations
//$permission = createUserPermission($newuserID,4,1,$clientID);
//Assign the master user ID to the client record
//setData($clientID,'tblclients','masteruserid',$newuserID);
}
else
{
echo 'A location ID was not found. Had to stop. Sorry about that!.';
ob_flush();
exit(0);
}
header( 'Location: onboarding_addemployee_complete.php?id='. $newuserID ) ;
ob_flush();
Does anyone know how to fetch all facebook ads statistics and display on webpage using Facebook Ads Api-PHP SDK. I am using this API and I am getting campaign details like name of campaign, id, status. but not able to get impressions,clicks, spent.
What I am doing let me share with you:
1) I am getting access token by authorizing user
2) After getting access token, I am using below code
$account = new AdAccount('act_XXXXXXXXXXXXXXX');
$account->read();
$fields = array(
AdCampaignFields::ID,
AdCampaignFields::NAME,
AdCampaignFields::OBJECTIVE,
);
$params = array(AdCampaignFields::STATUS => array(AdCampaign::STATUS_ACTIVE,AdCampaign::STATUS_PAUSED,),);
$campaigns = $account->getAdCampaigns($fields, $params);
/* Added By Jigar */
$campaign = new AdCampaign('XXXXXXXXXXXXXXXX');
$compainDetails = $campaign->read($fields);
3) then printing the array
echo "<pre>";
print_r($compainDetails);
exit;
If anyone know any suggestion in above code, please share. All code is in PHP. Dose anyone have any tutorial that fetch all above required data then share it
You could try to use the facebook insights api instead of $campaign->read. Here's an example:
https://developers.facebook.com/docs/marketing-api/insights/v2.5#create-async-jobs
What you have to do to get impressions, click and spent is to add these fields to the $fields param. In your case, the complete code should look like the following:
use FacebookAds\Object\Campaign;
use FacebookAds\Object\Values\InsightsLevels;
use FacebookAds\Object\Values\InsightsFields;
$campaign = new Campaign();
$fields = array(
InsightsFields::IMPRESSIONS,
InsightsFields::UNIQUE_CLICKS,
InsightsFields::CALL_TO_ACTION_CLICKS,
InsightsFields::INLINE_LINK_CLICKS,
InsightsFields::SOCIAL_CLICKS,
InsightsFields::UNIQUE_SOCIAL_CLICKS,
InsightsFields::SPEND,
);
$params = array(
'level' => InsightsLevels::CAMPAIGN,
);
$async_job = $campaign->getInsightsAsync($fields, $params);
$async_job->read();
I don't know what exactly the "click" param means for you, but if you take a look at all these click params, I'm sure you'll find it or you'll know how to calculate it.
For a complete list of fields available on insights objects, have a look at: https://github.com/facebook/facebook-php-ads-sdk/blob/master/src/FacebookAds/Object/Fields/InsightsFields.php
Hope that helps.
Regards, Benjamin
What is the best aproace of enriching c5 user's attributes.
I have non C5 table with users information this information was created on old cms (non c5), and im now building new site with c5 would like to know best aproach of migrating users.
Is it good idea to use SQL query or should i use php script for enriching, I already created users in to c5 and manualy added email addresses for "anchor point" for later enrichment.
Would be realy glad if someone could tell or maby could lead to some examples.
finaly managed by myself, its rather simple:
i exported external users to php array and used c5 user functions to add users and after enrich them my example:
$external_users = array({
array('id'=>'1', 'name'='JON', 'email'=>'blank#blank.blank', 'last_name'=>'DOE', 'attr1'=>'smthing', 'attr2'=>'123'),
array(...), ...
});
foreach($external_users as $singleUser_data){
$email = $singleUser_data['email'];
$ui = UserInfo::getByEmail($email);
if (!is_null($ui)) {
// Email is already in use, so let's not create the user
return;
}
$userData['uName'] = $singleUser_data['name']." ".$singleUser_data['lastname'];
//users later need to reset password
$userData['uPassword'] = 'asd52465465456454asd';
$userData['uPasswordConfirm'] = 'asd52465465456454asd';
//user registererd
$ui = UserInfo::register($userData);
set_new_user_group($ui);
enrichAtributes($ui, $singleUser_data);
}
function set_new_user_group($ui){
// assign the new user to a group
$g = Group::getByName('GroupName');
$u = $ui->getUserObject();
$u->enterGroup($g);
}
function enrichAtributes($ui, $singleUser_data){
$ui->setAttribute('atr_handler1', $singleUser_data['attr1']);
$ui->setAttribute('atr_handler2', $singleUser_data['attr2']);
}
Resource:
User registration programaticly and seting group
User information documentation (setting attributes)
I've managed to install the google API using composer and ZF2, and have successfully worked through the tribulation that is getting the P12 key, configuring the app, and configuring the Google_Client instance.
I've also managed to create events like so:
/** #var \Google_Service_Calendar $calendar */
$calendar = $this->getServiceLocator()->get('GoogleCalendar');
$event = new \Google_Service_Calendar_Event();
$event->setSummary( "This is a test" );
$dts = new \Google_Service_Calendar_EventDateTime();
$dts->setDateTime( date( "Y-m-d\\TH:i:s.000-04:00" ) );
$event->setStart( $dts );
$dte = new \Google_Service_Calendar_EventDateTime();
$dte->setDateTime( date( "Y-m-d\\TH:i:s.000-04:00", time() + 1800 ) );
$event->setEnd( $dte );
$att = array();
foreach( $emails as $e )
{
$attendee = new \Google_Service_Calendar_EventAttendee();
$attendee->setEmail( $e );
$att[] = $attendee;
}
$event->setAttendees( $att );
$x = $calendar->events->insert( "primary", $event, array( 'sendNotifications' => true ) );
return new JsonModel( array( 'success' => true ) );
The invitation comes from the application's client email, but I'd like to make it come from a particular email. How can I change the invitation?
Also, we subscribe to Google for Business ourselves; is it possible to create events within our business calendars rather than 'primary' on the app itself?
Thanks for your help!
Looking at the actually API documentation at Google, I'm not seeing a property to change who the calendar invite comes from. I'm not sure that would be a great thing to be able to do, you could then setup calendar events/invites from the CEO of a company about the company going out of business or some other crazy calendar invite without approval.
Your best bet would be to authorize the application for the account you want to use, then use the token from that account to insert calendar events.