phplist 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -0
- data/Manifest +7 -0
- data/README.md +48 -0
- data/README.rdoc +47 -0
- data/Rakefile +14 -0
- data/lib/phplist.rb +56 -0
- data/phplist.gemspec +29 -0
- metadata +60 -0
data/CHANGELOG
ADDED
File without changes
|
data/Manifest
ADDED
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# phplist
|
2
|
+
|
3
|
+
Api for phplist to subscribe to phplist.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install phplist
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
1 - :domain => 'mailer.example.com' # Your Phplist domain url
|
12
|
+
2 - :action => 'LCsub.php' # Your action php file
|
13
|
+
3 - :password => 'xxxxxx' # Your phplist password which you have mentioned in LCsub.php
|
14
|
+
4 - :ssl_enabled => false # Is ssl_enabled or not
|
15
|
+
|
16
|
+
Setup LCsub.php in your phplist project. (Download LCsub.php webservice from here.[LCsub.php](https://github.com/ahmadhussain/phplist_webservice))
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
You can use this by creating an instance:
|
20
|
+
|
21
|
+
phplist = Phplist::API.new({:domain => 'mailer.example.com', :action => 'LCsub.php', :password => 'xxxxxx', :ssl_enabled => false})
|
22
|
+
|
23
|
+
You could set the values in an initializer file in your app (e.g. your_app_path/config/initializers/phplist.rb).
|
24
|
+
|
25
|
+
Phplist::API.domain = 'mailer.example.com'
|
26
|
+
Phplist::API.action = 'LCsub.php'
|
27
|
+
Phplist::API.password = 'xxxxxx'
|
28
|
+
Phplist::API.ssl_enabled = false
|
29
|
+
|
30
|
+
If you have added in initializer then you don't need to pass this as function parameters.
|
31
|
+
|
32
|
+
phplist = Phplist::API.new
|
33
|
+
|
34
|
+
### Subscribe User to a list:
|
35
|
+
|
36
|
+
phplist.subscribe({:id => list_id, :subscriber => {:email => 'name@email.com'}})
|
37
|
+
|
38
|
+
|
39
|
+
### Subscribe a batch of users:
|
40
|
+
|
41
|
+
phplist.subscribe_list({:id => list_id, :subscribers => [{:email => 'name1@email.com'}, {:email => 'name2@email.com'}]})
|
42
|
+
|
43
|
+
### Subscribe multiple details:
|
44
|
+
|
45
|
+
You can also subscribe multiple details like name, city, country:
|
46
|
+
|
47
|
+
phplist.subscribe({:id => list_id, :subscriber => {:email => 'name@email.com', :name => 'name', :city => 'city', :country => 'country'}})
|
48
|
+
phplist.subscribe_list({:id => list_id, :subscribers => [{:email => 'name@email.com', :name => 'name', :city => 'city', :country => 'country'}, {:email => 'name2@email.com', :name => 'name2', :city => 'city2', :country => 'country2'}]})
|
data/README.rdoc
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# phplist
|
2
|
+
|
3
|
+
Api for phplist to subscribe to phplist.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install phplist
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
1 - :domain => 'mailer.example.com' # Your Phplist domain url
|
12
|
+
2 - :action => 'LCsub.php' # Your action php file
|
13
|
+
3 - :password => 'xxxxxx' # Your phplist password which you have mentioned in LCsub.php
|
14
|
+
4 - :ssl_enabled => false # Is ssl_enabled or not
|
15
|
+
5 - Setup LCsub.php in your phplist project. (Download LCsub.php webservice from here.[LCsub.php](https://github.com/ahmadhussain/phplist_webservice))
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
You can use this by creating an instance:
|
19
|
+
|
20
|
+
phplist = Phplist::API.new({:domain => 'mailer.example.com', :action => 'LCsub.php', :password => 'xxxxxx', :ssl_enabled => false})
|
21
|
+
|
22
|
+
You could set the values in an initializer file in your app (e.g. your_app_path/config/initializers/phplist.rb).
|
23
|
+
|
24
|
+
Phplist::API.domain = 'mailer.example.com'
|
25
|
+
Phplist::API.action = 'LCsub.php'
|
26
|
+
Phplist::API.password = 'xxxxxx'
|
27
|
+
Phplist::API.ssl_enabled = false
|
28
|
+
|
29
|
+
If you have added in initializer then you don't need to pass this as function parameters.
|
30
|
+
|
31
|
+
phplist = Phplist::API.new
|
32
|
+
|
33
|
+
### Subscribe User to a list:
|
34
|
+
|
35
|
+
phplist.subscribe({:id => list_id, :subscriber => {:email => 'name@email.com'}})
|
36
|
+
|
37
|
+
|
38
|
+
### Subscribe a batch of users:
|
39
|
+
|
40
|
+
phplist.subscribe_list({:id => list_id, :subscribers => [{:email => 'name1@email.com'}, {:email => 'name2@email.com'}]})
|
41
|
+
|
42
|
+
### Subscribe multiple details:
|
43
|
+
|
44
|
+
You can also subscribe multiple details like name, city, country:
|
45
|
+
|
46
|
+
phplist.subscribe({:id => list_id, :subscriber => {:email => 'name@email.com', :name => 'name', :city => 'city', :country => 'country'}})
|
47
|
+
phplist.subscribe_list({:id => list_id, :subscribers => [{:email => 'name@email.com', :name => 'name', :city => 'city', :country => 'country'}, {:email => 'name2@email.com', :name => 'name2', :city => 'city2', :country => 'country2'}]})
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('phplist', '0.1.0') do |p|
|
6
|
+
p.description = "Phplist subscriber"
|
7
|
+
p.url = "http://github.com/ahmadhussain/phplist"
|
8
|
+
p.author = "Ahmad Hussain"
|
9
|
+
p.email = "ahmadhmugl@gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/lib/phplist.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Phplist
|
5
|
+
class API
|
6
|
+
|
7
|
+
attr_accessor :domain, :action, :password, :ssl_enabled
|
8
|
+
def initialize(default_parameters = {:domain => nil, :action => nil, :password => nil, :ssl_enabled => false})
|
9
|
+
@domain = default_parameters[:domain]||self.class.domain
|
10
|
+
@action = default_parameters[:action]||self.class.action
|
11
|
+
@password = default_parameters[:password]||self.class.password
|
12
|
+
@ssl_enabled = default_parameters[:ssl_enabled]||self.class.ssl_enabled
|
13
|
+
end
|
14
|
+
|
15
|
+
def subscribe(info = {:id => nil, :subscriber => {:email => nil, :name => nil, :city => nil, :country => nil}})
|
16
|
+
return false if info[:id].blank?
|
17
|
+
return false if info[:subscriber].blank? || info[:subscriber][:email].blank?
|
18
|
+
p_email = info[:subscriber][:email]
|
19
|
+
name = info[:subscriber][:name]
|
20
|
+
p_name = CGI::escape(name||'')
|
21
|
+
|
22
|
+
p_city = CGI::escape(info[:subscriber][:city]||'')
|
23
|
+
p_country = CGI::escape(info[:subscriber][:country]||'')
|
24
|
+
|
25
|
+
start_time = Time.now
|
26
|
+
url = "http#{'s' if @ssl_enabled}://#{@domain}/#{@action}?password=#{@password}&email=#{p_email.downcase}&name=#{p_name}&city=#{p_city}&country=#{p_country}&makeconfirmed=1&lid=#{info[:id]}"
|
27
|
+
url = URI.encode(url)
|
28
|
+
uri = URI(url)
|
29
|
+
res = Net::HTTP.get_response(uri)
|
30
|
+
response_str = res.body.to_s
|
31
|
+
if /success/i =~ response_str
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
def subscribe_list(info = {:id => nil, :subscribers => [{:email => nil, :name => nil, :city => nil, :country => nil}]})
|
38
|
+
return false if info[:id].blank?
|
39
|
+
return false if info[:subscribers].blank?
|
40
|
+
subscribed = false
|
41
|
+
info[:subscribers].each do |subscriber|
|
42
|
+
subscribed = subscribe({:id => info[:id], :subscriber => subscriber})
|
43
|
+
return false unless subscribed
|
44
|
+
end
|
45
|
+
subscribed
|
46
|
+
end
|
47
|
+
|
48
|
+
class << self
|
49
|
+
attr_accessor :domain, :action, :password, :ssl_enabled
|
50
|
+
def method_missing(sym, *args, &block)
|
51
|
+
new({:domain => self.domain, :action => self.action, :password => self.password, :ssl_enabled => self.ssl_enabled}).send(sym, *args, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/phplist.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "phplist"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ahmad Hussain"]
|
9
|
+
s.date = "2013-11-27"
|
10
|
+
s.description = "Phplist subscriber"
|
11
|
+
s.email = "ahmadhmugl@gmail.com"
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.md", "README.rdoc", "lib/phplist.rb"]
|
13
|
+
s.files = ["CHANGELOG", "README.md", "README.rdoc", "Rakefile", "lib/phplist.rb", "phplist.gemspec", "Manifest"]
|
14
|
+
s.homepage = "http://github.com/ahmadhussain/phplist"
|
15
|
+
s.rdoc_options = ["--line-numbers", "--title", "Phplist", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = "phplist"
|
18
|
+
s.rubygems_version = "1.8.25"
|
19
|
+
s.summary = "Phplist subscriber"
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
else
|
26
|
+
end
|
27
|
+
else
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phplist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ahmad Hussain
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Phplist subscriber
|
15
|
+
email: ahmadhmugl@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- CHANGELOG
|
20
|
+
- README.md
|
21
|
+
- README.rdoc
|
22
|
+
- lib/phplist.rb
|
23
|
+
files:
|
24
|
+
- CHANGELOG
|
25
|
+
- README.md
|
26
|
+
- README.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- lib/phplist.rb
|
29
|
+
- phplist.gemspec
|
30
|
+
- Manifest
|
31
|
+
homepage: http://github.com/ahmadhussain/phplist
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options:
|
35
|
+
- --line-numbers
|
36
|
+
- --title
|
37
|
+
- Phplist
|
38
|
+
- --main
|
39
|
+
- README.rdoc
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.2'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project: phplist
|
56
|
+
rubygems_version: 1.8.25
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Phplist subscriber
|
60
|
+
test_files: []
|