I have an API end point set up on my server for Twilio to notify my server when an SMS/MMS is received.
Up until about 2 weeks ago, I was able to copy the media files of an MMS to my server using the PHP Copy function:
copy($sourceFile, $destinationFolder.$destinationFileName);
Where
$sourceFile = 'https://api.twilio.com/2010-04-01/Accounts/AC000000001/Messages/MM000000001/Media/ME000000001'
However, now, instead of getting the media file, I'm getting XML that describes the file:
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
<Media>
<Sid/>
<AccountSid>AC000000001</AccountSid>
<ParentSid/>
<ContentType/>
<DateCreated>Thu, 04 Apr 2019 15:31:30 +0000</DateCreated>
<DateUpdated>Thu, 04 Apr 2019 15:31:30 +0000</DateUpdated>
<Uri>/2010-04-01/Accounts/AC000000001/Messages/MM000000001/Media/ME000000001</Uri>
</Media>
</TwilioResponse>
Nothing has changed in my code and I can't find any documentation suggesting that Twilio was changing how things work.
I tried changing to a curl request and I get the same result. I also tried using the Twilio PHP SDK and following this documentation: https://www.twilio.com/docs/sms/api/media-resource#default-content-type
Does anyone have some insight as to what is happening/what changed and how to get around this?
If you look at the "ME000000001" from
$sourceFile = 'https://api.twilio.com/2010-04-01/Accounts/AC000000001/Messages/MM000000001/Media/ME000000001'
and then at the "ME000000001" from the XML response
<Uri>/2010-04-01/Accounts/AC000000001/Messages/MM000000001/Media/ME000000001</Uri>
they are different.
In fact for a message with, let's say 3 media attachments, the XML response will look something like:
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
<MediaList end="2" firstpageuri="/2010-04-01/Accounts/AC.../Messages/MM.../Media?Pag...>
<Media>
<Sid>ME...92c</Sid>
<AccountSid>AC...3e4</AccountSid>
<ParentSid>MM...e3d</ParentSid>
<ContentType>image/jpeg</ContentType>
<DateCreated>Tue, 09 Apr 2019 20:06:33 +0000</DateCreated>
<DateUpdated>Tue, 09 Apr 2019 20:06:33 +0000</DateUpdated>
<Uri>/2010-04-01/Accounts/AC...3e4/Messages/MM.../Media/ME...92c</Uri>
</Media>
<Media>
<Sid>ME...4ac</Sid>
<AccountSid>AC...3e4</AccountSid>
<ParentSid>MM...e3d</ParentSid>
<ContentType>image/jpeg</ContentType>
<DateCreated>Tue, 09 Apr 2019 20:06:33 +0000</DateCreated>
<DateUpdated>Tue, 09 Apr 2019 20:06:33 +0000</DateUpdated>
<Uri>/2010-04-01/Accounts/AC.../Messages/MM.../Media/ME...4ac</Uri>
</Media>
<Media>
<Sid>ME...048</Sid>
<AccountSid>AC...3e4</AccountSid>
<ParentSid>MM...e3d</ParentSid>
<ContentType>image/jpeg</ContentType>
<DateCreated>Tue, 09 Apr 2019 20:06:33 +0000</DateCreated>
<DateUpdated>Tue, 09 Apr 2019 20:06:33 +0000</DateUpdated>
<Uri>/2010-04-01/Accounts/AC.../Messages/MM.../Media/ME...048</Uri>
</Media>
</MediaList>
</TwilioResponse>
So, you'll find the media at the address in <Uri>...</Uri> (of course prepend with https://api.twilio.com).
Observe how the three Uris are different because they point to different media attached to the same message.
<Uri>/2010-04-01/Accounts/AC.../Messages/MM.../Media/ME...92c</Uri>
<Uri>/2010-04-01/Accounts/AC.../Messages/MM.../Media/ME...4ac</Uri>
<Uri>/2010-04-01/Accounts/AC.../Messages/MM.../Media/ME...048</Uri>
Related
I'm trying to use Lighthouse in GitLab CI to run a scan against a remote website after a deploy. The job keeps throwing an error.
My job configuration looks like this:
lighthouse:
stage: scan
image: markhobson/node-chrome
script:
- npm install -g lighthouse lighthouse-plugin-field-performance --unsafe-perm
- lighthouse $URL --plugins=lighthouse-plugin-field-performance --chrome-flags=”--headless --no-sandbox” --verbose
I've also tried with image: buildkite/puppeteer. In both instances I get a similar error when I try to invoke Lighthouse, which looks like this:
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose created /tmp/lighthouse.KXhqWF0
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose Launching with command:
"/usr/bin/google-chrome-stable" --disable-translate --disable-extensions --disable-background-networking --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --remote-debugging-port=44495 --disable-setuid-sandbox --user-data-dir=/tmp/lighthouse.KXhqWF0 about:blank
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose Chrome running with pid 36 on port 44495.
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher Waiting for browser.
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher Waiting for browser...
Wed, 09 Oct 2019 20:22:43 GMT ChromeLauncher Waiting for browser.....
Wed, 09 Oct 2019 20:22:43 GMT ChromeLauncher Waiting for browser.......
Wed, 09 Oct 2019 20:22:44 GMT ChromeLauncher Waiting for browser.........
Wed, 09 Oct 2019 20:22:44 GMT ChromeLauncher Waiting for browser...........
etc
Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:44495
Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error Logging contents of /tmp/lighthouse.KXhqWF0/chrome-err.log
Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error
(google-chrome-stable:36): Gtk-WARNING **: cannot open display:
[1009/202244.656645:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
Unable to connect to Chrome
I'm not entirely sure what I need to do at this point. I'm questioning whether or not to try a more basic node image and try installing what I need manually, which I tried originally and found that managing Chrome/Chromium with Lighthouse was not quite as straight-forward as I wanted. Any thoughts or suggestions?
You could try using this image which has both everything installed ready to execute a report https://hub.docker.com/r/femtopixel/google-lighthouse/
My db is by default storing times as such:
Object.last.created_at
# => Fri, 03 Jul 2015 23:27:50 UTC +00:00
I looked at the strftime docs and I can build that myself, but it seems there must be an easy way to get a regular Date object to that format? Just wondering if there is...
to_datetime gets really close, but not exactly all the way there.
Date.today.to_datetime
# => Sat, 04 Jul 2015 00:00:00 +0000
Any other ideas?
Try this
Time.zone.now
#=> Sat, 04 Jul 2015 20:32:44 UTC +00:00
UPDATE
DateTime.now.in_time_zone
#=> Sat, 04 Jul 2015 20:43:57 UTC +00:00
Oh silly me... it's just
Date.today.in_time_zone
# => Mon, 06 Jul 2015 00:00:00 UTC +00:00
I am using AVPlayer to play some mp3 link, the file is just 1.8MB and I could download it, browser can also play it, but the app crashes (for other mp3 links it works) with the following information:
(951,0xac82aa28) malloc: * mmap(size=2147483648) failed (error
code=12)
error: can't allocate region
** set a breakpoint in malloc_error_break to debug
It fails even if the mp3 links is played first (ie there is no previous players created and not released in memory), so why do I still get the memory not enough error? I was thinking that it might be caused by the HTTP header when getting the stream, but the header looks fine:
HTTP/1.1 200 OK
Content-Length: 1872792
Date: Mon, 05 Aug 2013 00:19:10 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Thu, 25 Jul 2013 02:06:19 GMT
Etag: "1c9398"
Accept-Ranges: bytes
Cache-Control: max-age=0
Expires: Mon, 05 Aug 2013 00:19:10 GMT
Connection: close
Content-Type: audio/mpeg
Can anyone help?
Thanks
I got this error and makes me crazy.
My desired output is shows the week starting at sunday and after that calculate 10 weeks ago based on that.
Example:
[Sun, 12 Aug 2012, Sun, 05 Aug 2012, Sun, 29 Jul 2012, Sun, 22 Jul
2012, Sun, 15 Jul 2012, Sun, 08 Jul 2012, Sun, 01 Jul 2012, Sun, 24
Jun 2012, Sun, 17 Jun 2012, Sun, 10 Jun 2012, Sun, 03 Jun 2012]
But at my machine it's correctly and return the array above, however at the server is wrong :(
The output at server is:
[Sat, 11 Aug 2012, Sat, 04 Aug 2012, Sat, 28 Jul 2012, Sat, 21 Jul
2012, Sat, 14 Jul 2012, Sat, 07 Jul 2012, Sat, 30 Jun 2012, Sat, 23
Jun 2012, Sat, 16 Jun 2012, Sat, 09 Jun 2012, Sat, 02 Jun 2012]
If I access the app and call the controller from script/console shows wrong but If I recalculate at script/console shows correctly.
My environment:
OS X 10.7.4, ruby 1.8.7 (2012-04-14 patchlevel 361)
[i686-darwin11.3.0], rvm 1.10.2, Seg 13 Ago 2012 09:27:46 BRT (system
date)
And server environment:
Ubuntu 12.04, ruby 1.8.7 (2012-02-08 MBARI 8/0x8770 on patchlevel 358)
[i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2012.02, rvm
1.14.0 (stable), Mon Aug 13 13:29:13 WEST 2012
Probably a time zone mismatch on your server, try setting your time zone explicitly in config/appliction.rb:
config.time_zone = "Pacific Time (US & Canada)"
A popular solution to this issue is setting a before_filter on your controller that configures the right time zone per user. See: http://railscasts.com/episodes/106-time-zones-in-rails-2-1 for a starting point.
i've seen a bunch of topics about setting the MIME types.
But, no one helped me.
He is my problem:
I have a Rails website with bunch of video in .ogv and .mov formats, located in /public folder.
I refer to these files in HTML5 video tag.
There is no problem with .mov files, they are played nice in WebKit browsers.
The problem is with .ogv.
I think, it's because wrong MIME type for .ogv.
Here is what i get for .mov (correct):
$ curl -I http:/mywebsite.com/video.mov
HTTP/1.1 200 OK
Date: Sun, 03 Apr 2011 19:57:41 GMT
ETag: "4d98744c-1bb-87563c0"
Last-Modified: Sun, 03 Apr 2011 13:21:16 GMT
Content-Type: video/quicktime
Content-Length: 443
And here is what i get for .ogv:
$ curl -I http://mywebsite.com/video.ogv
HTTP/1.1 200 OK
Date: Sun, 03 Apr 2011 19:22:20 GMT
ETag: "4d987dcf-379884-81c533dc"
Last-Modified: Sun, 03 Apr 2011 14:01:51 GMT
Content-Type: application/octet-stream
Content-Length: 3643524
Instead of "application/octet-stream" i need "video/ogg".
I have a Mongrel server (no Apache as front-end), as i recently got to know. So, there is no way to use .htaccess.
I need to set MIME-type for regular files, not responses from controller etc.
I've tried several ways, described in my previous question: HTML 5 video (ogv) and MIME types
But i does't works. I still get "application/octet-stream".
My Questions are:
How can i set mime types for regular files, not responses from controller ?
Does Mongrel serves files, located in /public directory, or something else ?
I've figured it out.
All the methods, described in my previous question are setting MIME-types for Rails environment, not Mongrel.
I need additional MIME-types at Mongrel level, not Rails.
So, by starting mongrel via …
/usr/bin/mongrel_rails,
… I need to pass a YAML file to it, that contains additional MIME-types, i want to declare. This YAML file might look like this (mongrel_mime_types.yml):
.ogv: video/ogg
.ogg: application/ogg
.ogx: application/ogg
I keep it in /config/initializers, for convenience.
So, by starting Mongrel, i need to pass this file:
/usr/bin/mongrel_rails -m /path_to_my_project/http/config/initializers/mongrel_mime_types.yml
Now, if i check with curl, I'm getting correct MIME:
$ curl -I http://mywebsite.com/video.ogv
HTTP/1.1 200 OK
Date: Mon, 04 Apr 2011 05:38:01 GMT
ETag: "4d987dcf-379884-81c533dc"
Last-Modified: Sun, 03 Apr 2011 14:01:51 GMT
Content-Type: video/ogg
Content-Length: 3643524