onesignal api php not detecting "send_after" parameter - php

I am sending this value to send_after parameter with php: "2022-12-28 11:47:00 GMT+300"
but the notification does not come at the time I choose, it comes instantly.
$date = date_create("2022-12-28 11:47");
echo $date2 = date_format($date,"Y-m-d H:i:s")." GMT+300";
// output: 2022-12-28 11:47:00 GMT+300
https://documentation.onesignal.com/reference/create-notification
I send it in the correct format according to the document, but still notifications come instantly, not when I choose

Related

Why is FB/Meta Conversions API not deduplicating my events even though they have the same name and eventID?

I send the same event to Facebooks Event Manager from FB pixel and Conversions API.
I have made sure that the event name and eventID are the exact same, and that the server event is sent after the browser event.
The events are not deduplicated in Event Manager. I have looked through the documentation but can´t find anything missing.
I have tried on several different types of events and waited more than 24 hours.
The Pixel event is sent like this;
fbq('track', 'PageView', {test: 'test'}, {eventID: 'PageView'+uniqueid});
And i use Facebook Business SDK for PHP to send server events;
Api::init(null, null, $access_token, false);
$user_data = (new UserData())
->setClientIpAddress($_SERVER['REMOTE_ADDR'])
->setClientUserAgent($_SERVER['HTTP_USER_AGENT']);
$event = (new Event())
->setEventName($eventname)
->setEventId($eventid)
->setEventTime(time())
->setEventSourceUrl($_SERVER['HTTP_REFERER'])
->setUserData($user_data);
return array($event);
}
$request = (new EventRequest($pixel_id))
->setTestEventCode('TESTXXXX')
->setEvents(create_events($eventid, $eventname));
$response = $request->execute();
Here is an example of an event that is not deduplicated;
It seems to be working fine when using a public server instead a local one.
Then i also get the users IP-address in the server event. I guess the IP address differs between the pixel and the PHP variable $_SERVER['REMOTE_ADDR'] locally (127.0.0.1) and that is what prevents the server event to be deduplicated.

Piwik tracking API returns GIF89

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?

Gmail oauth received on date using PHP

How do I go about getting a count of emails received on a particular date across all gmail folders. Managed to get email inbox counting working ok but now need to figure out how to get number received for previous day using PHP and oauth. Can anyone help?
The messages#list method allows you to pass a q parameter which accepts the same query format from the Gmail search field.
Thus it's possible to do this:
// $gmail is an instance of Google_Service_Gmail
$messages = $gmail->users_messages->listUsersMessages('me', array(
'q' => "after:2014/10/20 before:2014/10/21"
));
// $count is the number of messages from 2014/10/20
$count = $messages->getResultSizeEstimate();
Beware that the result will be different from what you see in Gmail if you have the 'Conversation view' turned on.

PHP- No connection could be made because the target machine actively refused it

I am trying to obtain client's time zone for one of my projects using PHP. Saw a post in stackoverflow with solutions for what I was looking for. Here's the link to that post.
get user timezone
I followed the most upvoted solution but it produced an error something like this.
Suppose $_SERVER['REMOTE_ADDR'] returns 212.88.207.202 to $ip, I hardcoded that value to $ip in my develpoment phase.
It doesn't matter since hardcoding 212.88.207.202 or using $_SERVER['REMOTE_ADDR'] this returns the same value to $ip.
But when I run the page, I get this error.
Warning: file_get_contents(http://smart-ip.net/geoip-json/212.88.207.202): failed to open stream: No connection could be made because the target machine actively refused it.
Here's the code
<?php
$ip = '212.88.207.202'; // means we got user's IP address
$json = file_get_contents( 'http://smart-ip.net/geoip-json/' . $ip); // this one service we gonna use to obtain timezone by IP
// maybe it's good to add some checks (if/else you've got an answer and if json could be decoded, etc.)
$ipData = json_decode($json, true);
//var_dump($ipData);
if ($ipData['timezone']) {
$tz = new DateTimeZone( $ipData['timezone']);
$now = new DateTime( 'now', $tz); // DateTime object corellated to user's timezone
} else {
// we can't determine a timezone - do something else...
}
?>
Where did I go wrong???
Well.....the problem is with the target machine. I tried opening smart-ip.net in my browser, but I wasn't able to do so. I think they are no longer running their service. That is the reason why target machine actively refused my connection. Viola!

Post a scheduled feed with Facebook sdk

When I try to post a scheduled feed, I send beyond the normal parameters I send published parameter and scheduled_publish_time. But the error message "Uncaught OAuthException: (# 100) The specified scheduled publish time is invalid." Already made ​​several changes to the format of the date I got no more success.
The last one I tried is:
$date = date_parse_from_format('d/m/Y H:i:s', '31/05/2013 22:00:00');
$date = gmdate (DATE_ISO8601, mktime($date['hour'],$date['minute'],$date['second'],$date['month'],$date['day'],$date['year']));
$content['scheduled_publish_time'] = strtotime($ date);
When I got the error it was because the scheduled_publish_time I was setting was less than 10 minutes.
According to facebook the "time when the page post should go live, this should be between 10 mins and 6 months from the time of publishing the post".
https://developers.facebook.com/docs/reference/api/page/
Also it must be a unix epoch timestamp and you don't have to worry about timezones either.
Hope this helps.
UPDATE:
I use the Facebook PHP SDK.
$post = $facebook->api("/v2.2/$pageName/$insight", 'post', $args);
and in my $args variables I have
$args = array(
'scheduled_publish_time' => $epochTime,
'published' => 0
);
where $epochTime is something like this
$epochTime = strtotime("2015-04-07 09:00:00");

Categories