Everybody Staze...

Nobody leavz...

  • Home
  • About Me
    • LinkedIn
    • Lab
  • Contact
  • Links
  • Reviews
  • Sitemap
  • Weather
You are here: Home / Archives for PHP

Retrieving steps data from Fitbit API

2013/12/21 By staze

phpI recently got a FitBit One (review forthcoming), and one of the big reasons I got it was their open API. Basically, the FitBit will sync over Bluetooth 4.0 (Lower Power) when it sees it’s Dongle, or if you have an iPhone/Android phone, it can sync to that in the background. That data syncs up to the FitBit website, at which point you can pull the data back down using their API… at least, that was my hope.

After playing with things for a few days, I finally got this working, and my steps information will now dynamically update. I still am not sure how I’ll correct for issues like being out of town, etc… but I’ll figure something out.

Anyway, since no one seems to have detailed how to do this with PHP, I thought I would here. This is all assuming you’ll only be grabbing your own info.

[Read more…]

Filed Under: Coding Tagged With: fitbit, Pedometer, PHP

PHP 5.3.1 compiled from source on 10.6.2 Server

2010/02/03 By staze

UPDATE: Please take a look at this. The below is pretty outdated at this point since Apple shipped PHP 5.3.4 with 10.6.8, and 10.7.0 shipped with 5.3.6. Their script is much spiffier than mine. Thanks!

Apple unfortunately forgot to include freetype support in GD with their stock version of PHP 5.3.0 in 10.6 Server at least up to 10.6.2.

So, there’s some info online about compiling freetype into GD in 10.6, but it doesn’t specifically address 10.6 Server, and it references downloading the PHP 5.3.0 source from Apple’s servers, rather than directly from php.net.

So, here’s the info.

  1. Create a directory for the src.
    sudo mkdir /src
  2. Chown that over to yourself.
    sudo chown username /src
  3. Change into that directory.
    cd /src
  4. Create pcre directory.
    mkdir pcre
  5. Change into pcre directory.
    cd pcre
  6. Download pcre source.
    curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz -O
  7. Download php5.3.1 source.
    curl http://us3.php.net/distributions/php-5.3.1.tar.gz -O
  8. Download libjpeg-v7 source.
    curl http://www.ijg.org/files/jpegsrc.v7.tar.gz -O
  9. Untar all of the above.
    find *.tar.gz -exec tar xfvz {} \;
  10. Change into pcre source directory.
    cd pcre-8.01
  11. configure pcre.
    ./configure --disable-shared --enable-static
  12. Make, and install pcre.
    make && make install DESTDIR=/src/pcre/pcre-local
  13. Change into the jpeg directory.
    cd ../../jpeg-7
  14. Copy some config files into the current directory.
    cp /usr/share/libtool/config/config.sub .; cp /usr/share/libtool/config/config.guess .
  15. Config libjpeg.
    export MACOSX_DEPLOYMENT_TARGET=10.6
    CFLAGS="-arch x86_64" \
    CXXFLAGS="-arch x86_64" \
    LDFLAGS="-arch x86_64" \
    ./configure --enable-shared
  16. Make, and Make install.
    make; sudo make install
  17. Change directory into PHP source folder.
    cd ../php-5.3.1
  18. Modify line 186 of ./ext/iconv/iconv.c and change #define iconv libiconv to #define iconv iconv
  19. Configure PHP.
    MACOSX_DEPLOYMENT_TARGET=10.6
    CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp"
    CCFLAGS="-arch x86_64 -g -Os -pipe"
    CXXFLAGS="-arch x86_64 -g -Os -pipe"
    LDFLAGS="-arch x86_64 -bind_at_load"
    export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
    ./configure --prefix=/usr \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info \
    --disable-dependency-tracking \
    --sysconfdir=/private/etc \
    --with-apxs2=/usr/sbin/apxs \
    --enable-cli \
    --with-config-file-path=/etc \
    --with-libxml-dir=/usr \
    --with-openssl=/usr \
    --with-kerberos=/usr \
    --with-zlib=/usr \
    --enable-bcmath \
    --with-bz2=/usr \
    --enable-calendar \
    --with-curl=/usr \
    --enable-exif \
    --enable-ftp \
    --with-gd \
    --with-jpeg-dir=/usr/local/lib \
    --with-png-dir=/usr/X11R6 \
    --with-freetype-dir=/usr/X11R6 \
    --with-xpm-dir=/usr/X11R6 \
    --with-ldap=/usr \
    --with-ldap-sasl=/usr \
    --enable-mbstring \
    --enable-mbregex \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-mysql-sock=/var/mysql/mysql.sock \
    --with-iodbc=/usr \
    --enable-shmop \
    --with-snmp=/usr \
    --enable-soap \
    --enable-sockets \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --with-xmlrpc \
    --with-iconv-dir=/usr \
    --with-xsl=/usr \
    --with-pcre-regex=/src/pcre/pcre-local/usr/local
  20. Make PHP.
    export EXTRA_CFLAGS="-lresolv"; make
  21. Backup your php.ini
    sudo cp /private/etc/php.ini /private/etc/php.ini.bak
  22. Install new PHP
    sudo make install
  23. Restore php.ini, and restart apache.
    sudo cp /private/etc/php.ini.bak /private/etc/php.ini; sudo apachectl graceful

All and all, on a new mac mini server, this took about 20-30 minutes. And I now have a working PHP 5.3.1 install, and freetype now works with GD (allowing me to put the captcha back on my contact form under “About”. Good luck!

Reference Links:

  • http://www.gen-x-design.com/archives/recompiling-php-5-3-on-snow-leopard-with-freetype-support/
  • http://diymacserver.com/installing-php/adding-the-gd-module-to-php-on-snow-leopard/

Filed Under: Sys Admin Tagged With: 10.6, Freetype, GD, PHP

PHP 5.3 upgrade

2010/01/11 By staze

UPDATE: It appears there is a problem with the Entropy build of PHP 5.3.0, which prevents fopen’s from working. Not sure if it’s because it’s running on a PPC, or if there’s just something up with the build. At this point, I’ve moved back to PHP 5.2.9. In the next month or so, I’ll probably move back to PHP 5.3.1, but there will be more about that later.

So, yesterday I spent a good chunk of the day working on my website. I started with converting a couple scripts I run on the site (my gas info on the right, my power history, etc) from PEAR MDB2 to PDO. This really wasn’t that bad, and PDO seems faster, but it could just be perception.

More importantly, I upgraded PHP on the server to 5.3.0 from 5.2.9. For the most part, everything worked great… though Twitter Tools has stopped grabbing new tweets, and a few WordPress plugins are throwing errors dealing with strpos() rss.php.

The twitter tools error thrown is:
[Mon Jan 11 21:24:50 2010] [error] [client 10.0.2.1] PHP Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /path/to/website/wp-includes/class-snoopy.php on line 1142
[Mon Jan 11 21:24:50 2010] [error] [client 10.0.2.1] PHP Warning: fsockopen(): unable to connect to twitter.com:80 (php_network_getaddresses: getaddrinfo failed: System error) in /path/to/website/wp-includes/class-snoopy.php on line 1142

And yes, allow_url_fopen is enabled. Can’t figure it out at all.

The error other plugins are throwing is:
strpos() expects parameter 1 to be string, array given in /path/to/website/wp-includes/rss.php on line 577

I hope to get these fixed… but at this point, I can’t figure out what’s going on. =(

Obviously the possibilities are:

  • Bug in php
  • Bug in scripts
  • Some misconfiguration in php.ini

I don’t think it’s the last option, but I’m not 100% positive.

Anyway… that’s all for now.

Happy new year!

Filed Under: Sys Admin Tagged With: PDO, PHP, Twitter Tools, Wordpress

« Previous Page
Next Page »

Weather

Categories / Archives

  • Apple
  • Coding
  • Electronics
  • Energy
  • Home Ownership
  • Miscellany
  • Politics
  • Prius
  • Sys Admin
  • Travel
  • Uncategorized
  • Work
  • June 2026
  • April 2026
  • August 2025
  • April 2025
  • January 2024
  • February 2021
  • July 2020
  • January 2020
  • April 2019
  • March 2018
  • February 2018
  • June 2017

Copyright © 2026 · Staze On Genesis Framework · WordPress · Log in