I try to get this tutorial to work:

function post_simple_message() {
  $request =
    new HttpRequest('https://api.mailgun.net/v2/samples.mailgun.org/messages',
  $auth = base64_encode('api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
  $request->setHeaders(array('Authorization' => 'Basic '.$auth));
    ->setPostFields(array('from' => 'Excited User'.
                          ' <Excited User <me@samples.mailgun.org>>',
                          'to' => 'sergeyo@profista.com, serobnic@mail.ru',
                          'subject' => 'Hello',
                          'text' => 'Testing some Mailgun awesomness!'
  return $request;

Unfortunately that produces:

Fatal error: Class 'HttpRequest' not found in index.php on line 2not found in index.php on line 2

As suggested here I tried adding a php.ini to my webapp containing:

extension = php_http.dll   
extension = pecl_http.dll

I also checked with phpinfo that my php.ini is parsed.

Any more ideas?

asked 03 Mar '12, 07:11

ampelmann's gravatar image

accept rate: 0%


You need to install the pecl_http PHP extension first. Here's the procedure to install it:

mkdir ~/pecl_install
cd ~/pecl_install
wget http://pecl.php.net/get/pecl_http-1.7.1.tgz
tar zxf pecl_http-1.7.1.tgz
cd pecl_http-1.7.1
./configure --with-php-config=/usr/local/bin/php53-config
mkdir ~/php53-exts
cp modules/http.so ~/php53-exts/
ln -s /usr/local/lib/php53/extensions/no-debug-non-zts-20090626/* ~/php53-exts/
echo "extension_dir = $HOME/php53-exts" >> ~/webapps/<appname>/php.ini
echo "extension = http.so" >> ~/webapps/<appname>/php.ini

You should then be able to use the HttpRequest class.

permanent link

answered 03 Mar '12, 07:44

todork's gravatar image

accept rate: 34%

Awesome! Thanks for the quick help as always. You guys rock.

(03 Mar '12, 13:34) ampelmann ampelmann's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 03 Mar '12, 07:11

question was seen: 11,499 times

last updated: 03 Mar '12, 13:34

Features & prices    Sign up    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
© Copyright 2003-2015 Swarma Limited - WebFaction is a service of Swarma Limited