I try to get this tutorial to work:

function post_simple_message() {
  $request =
    new HttpRequest('https://api.mailgun.net/v2/samples.mailgun.org/messages',
                    HttpRequest::METH_POST);
  $auth = base64_encode('api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
  $request->setHeaders(array('Authorization' => 'Basic '.$auth));
  $request
    ->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!'
                          ));
  $request->send();
  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

ampelmann
35317
accept rate: 0%


Hi,

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
phpize53
./configure --with-php-config=/usr/local/bin/php53-config
make
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.

link

answered 03 Mar '12, 07:44

todork's gravatar image

todork
1.1k4
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

By RSS:

Answers

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

Tags:

×183

Asked: 03 Mar '12, 07:11

Seen: 6,203 times

Last updated: 03 Mar '12, 13:34

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited