Using the PHP Client Library through a Proxy connection


To access a Google Data API through a proxy connection you will need to use the Zend_Http_Client_Adapter_Proxy proxy adapter. In the snippet below, we are going to access our private Google Documents feed from the DocumentsList API through a proxy connection:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_App_HttpException');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');

Zend_Loader::loadClass('Zend_Http_Client_Exception');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy');


// Configure the proxy connection
$config = array(
    'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
    'proxy_host' => 'your.proxy.server.net',
    'proxy_port' => 3128
);

// We are setting http://www.google.com:443 as the initial URL since we need to perform
// ClientLogin authentication first.
$proxiedHttpClient = new Zend_Http_Client('http://www.google.com:443', $config);

$username = 'foo@example.com';
$password = 'barbaz';
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;

// Try to perform the ClientLogin authentication using our proxy client.
// If there is an error, we exit since it doesn't make sense to go on. You may want to 
// modify this according to the needs of your application.
try {
  $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service,
    $proxiedHttpClient);
} catch (Zend_Gdata_App_HttpException $httpException) {
  exit("An error occurred trying to connect to the proxy server\n" .        
    $httpException->getMessage() . "\n");
}

// If that worked, proceed and retrieve the documents feed.
// Remember to set your application ID.
$docsClient = new Zend_Gdata_Docs($httpClient, $yourApplicationId);
$feed = $docsClient->getDocumentListFeed();

?>

48 comments:

o_Ojack said...

I have exactly the same code, but I am getting the following error message: "Fatal error: Call to undefined method Zend_Http_Client::setClientLoginToken() in C:\xampp\php\ZendGdata\library\Zend\Gdata\ClientLogin.php on line 155"

Which is strange because Client.Login.php is the framework's code. Please advice, I have been stucked on this for a few days :(

Eric (Google) said...

Try using Zend_Gdata_HttpClient instead of Zend_Http_Client

Fernando F. Gallego said...

What if proxy requires user and password to access through it?

Thanks

Eric (Google) said...

Can't you pass the proxy_user/proxy_pass as a config option to the adaptor?

http://framework.zend.com/manual/en/zend.http.client.adapters.html

zengzhen said...

Great,
I am searching the php code using Proxy.
My question is that must we use the Zend library?
are there any other options?
thanks.
http://net-kane.com

TickMc said...

I am trying to use this code but am getting the same error as o_Ojack. Eric's suggestion to use Zend_Gdata_HttpClient instead of Zend_Http_Client is not clear and generates other errors.

Can you post corrected script with you suggestion in place, please?

Thanks,

Mike

TickMc said...

I managed to get the following working:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_App_HttpException');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');

Zend_Loader::loadClass('Zend_Http_Client_Exception');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy');


// Configure the proxy connection
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
'proxy_host' => 'your.proxy.server.net',
'proxy_port' => 3128
);

// We are setting http://www.google.com:443 as the initial URL since we need to perform
// ClientLogin authentication first.
$proxiedHttpClient = new Zend_Gdata_HttpClient('http://www.google.com:443', $config); /*******changed line *******/

$username = 'foo@example.com';
$password = 'barbaz';
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;

// Try to perform the ClientLogin authentication using our proxy client.
// If there is an error, we exit since it doesn't make sense to go on. You may want to
// modify this according to the needs of your application.
try {
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service,
$proxiedHttpClient);
} catch (Zend_Gdata_App_HttpException $httpException) {
exit("An error occurred trying to connect to the proxy server\n" .
$httpException->getMessage() . "\n");
}

// If that worked, proceed and retrieve the documents feed.
// Remember to set your application ID.
$docsClient = new Zend_Gdata_Docs($httpClient, $yourApplicationId);
$feed = $docsClient->getDocumentListFeed();

Anonymous said...

Once you enter PeekShows.com you will have immediate access to Free Live Webcams. Cam to cam with hot nude porn models right now! Free live porno sex videos, in real time. Its Free Porn and Free Live Sex for the common man! PeekShows Girls are waiting right now and 24/7 to watch you and engage in cam to cam sex with you! PeekShows Cam Models want to watch you stroke your cock just for them on web cam to cam, while they play with their pussys and please you in the hottest sexchat on earth! Join now and claim your free lifetime membership to PeekShows.com! Only you decide when it is time to purchase tokens on PeekShows.com for your own sneak peek, tokens which you will use for hot 1on1 private action with your favorite model! Sexting your favorite models are waiting to please you, don't make them wait for a quick peek. ;)
free cam to camred sexy lingerie

Consultant Afaceri said...

Same thing at Consultanta-Plan-Afaceri.eu

Hiphop4Cash said...

Which is strange because Client.Login.php is the framework's code. Please advice, I have been stucked on this for a few days :(
Elektriske dildoerGold Coast Escorts

kosovohp03 said...

healthtips
healthtips
healthtips
healthtips
healthtips




socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
socks proxy
check socks proxy
socks proxy
socks proxy






funnystory
funnystory
funnystory
funnystory
funnystory




funny pictures
funny pictures
funny pictures
funny pictures
funny pictures
funny pictures






Girl Xinh
Girl Xinh
Girl Xinh
Girl Xinh
Girl Xinh
Girl Xinh
Girl Xinh





cute animal
food news
internet
football news
bank news
marketing
science news
travel vietnamt
real estate vietnam
business news
music news
health news
software
seo news

kosovohp03 said...

Girl Xinh | Hot Girl | Cute Girl | Sexy Girl |Hot Girl Asian | Hot Girl Xinh
Funny Story | Funny Stories | Funny | lol
Funny Pictures | funny | lol
Girl Xinh | Hot Girl | Cute GirlSexy Girl |Hot Girl Asian | Hot Girl Xinh | lexi belle | ngoc trinh

Unknown said...

Hello, Thank you for the post i have a question please.
where would i get the "$yourApplicationId"
& am getting "Fatal error: Class 'Zend_Http_Client'"
could you please advs on how i can fix this?
thx

Unknown said...

Là đơn vị hàng đầu về thiết kế nội thất chung cư, chuyên thiết kế biệt thự và thi công thiết kế nội thất đồng thời cho thuê áo dài tại hà nội đẹp

Unknown said...

Okay, she kinda looks like she’s going to jail, but I promise she’s not. I’m way into dich vu bao cao thue uneven rows of braids right now and I had a good idea (or at least I think it is) and wanted to share. I’m heading out for vacation in a week or so and I really needed some kind of rad pool hair situation since I plan on being in it most of the time I’m away. So I decided to combine my normal pool dịch vụ kế toán thuế
dịch vụ quyết toán thuế
dịch vụ hoàn thiện sổ sách kế toán
strategy with a cool girl hair look. Here’s how I’ll be keeping my red hair fresh Trung tâm đào tạo kế toán tại hà đông
Dịch vụ kế toán tại tp hcm
while I’m maxing + relaxing…

Unknown said...

thiet ke nha pho dep
dich vu giat tham tai nha
giat tham van phong
thiet ke biet thu dep

Heo Hồng said...

chung cu gemek du an gemek premium mo bat dot moi nam 2016.
Du an can ho cao cap Gemek Premium chinh thuc mo ban dot 1.
Danh sach chung cu Ha Noi can ho chung cu cac quan Ha Dong, Cau Giay, Hoang Mai….
FLC Group ra mat du an cao cap tai Ha Dong du an flc quang trung voi quan the tien ich chat luong cao.
Mot du an cao cap voi quan the can ho chung cu va biet thu lien ke chung cu flc garden city quan nam Tu Liem, Ha Noi.
Mot du an cao cap voi quan the can ho chung cu Tay Ho chung cu 69b thuy khue chu dau tu SUN GROUP.
Chung cu mat duong Nguyen Xien Eco Green City mo ban block Eco Spring.
chung cu cao cap Tay Ho du an ecolife tay ho mo ban dot 1.
Biet thu lien ke the green daisy thuoc the green manor.

Bàn ghế xếp thông minh said...

Giày nam da cá sấu
Ví nam da cá sấu
Ví nữ da cá sấu
Thắt lưng nam da cá sấu
Thắt lưng nam da cá sấu

Dương Phạm said...

cong tu dong
cổng tự động
cong tu dong Barrier
cua tu dong Barrier
cua tu dong
cửa tự động
barrier tự động
barie tự động
barie tu dong
barrier tu dong
cổng barie
barie tu dong
máy dò kim loại
may do kim loai
may do kim loai cam tay
may do kim loai cam tay
máy dò kim loại bằng tay
may do kim loai cam tay
may do kim loai bang tay

Unknown said...

thiet ke xay dung nha dep
thiet ke nha pho dep
thiet ke biet thu dep
cong ty xay dung tphcm
giat tham

Unknown said...

chung cư tân hoàng minh Trần duy hưng
Chung cư D’.Le Jardin du Luxembourg
D’.Le Jardin du Luxembourg Trần Duy Hưng
Dự án Tân hoàng minh Trần duy hưng
D’.Le Jardin du Luxembourg

Hương Mộc said...

Chung cư Phú Mỹ complex, thiết kế căn hộ Phú Mỹ Complex,mở bán đợt 2 chung cư Phú mỹ Complex,các yếu tố phong thủy tại căn hộ chung cư,ảnh hưởng của khí hậu-Ngập lụt nhiều nhưng tại khu Ngoại giao Đoàn không bị ngập lụt,chung cư taseco complex,giới thiệu chung cư N03T2 ngoại giao Đoàn,chung cư N01T4 triển khai xây dựng,chung cư Taseco Complex mở bán đợt cuối.

Dương Phạm said...

Chung cư Tân Hoàng Minh Quảng An
Tân Hoàng Minh Quảng An
Dự án Tân Hoàng Minh Quảng An
D’.Le Roi Soleil
chung cư quảng an tây hồ
Chung cư D’.Le Roi Soleil

Trantuyen said...

cám ơn bạn, bài viết rất hay
tham khảo thêm nhưng thông tin hữu ích tại đây
cám ơn
chung cư hà nội
chung cư gamuda giai đoạn 2
chung cư gamuda
liền kề gamuda
biệt thự gamuda
an bình city
the golden palm
liền kề gamuda
biệt thự gamuda
Chung cư the wings
chung cư công viên yên sở
biệt thự gamuda
liền kề gamuda
Gamuda gardens
Liền kề gamuda
vinhomes thăng long
dự án vinhomes thăng long
biệt thự gamuda
Liền kề gamuda

Anonymous said...

avava dalian satas
hargamesinterbaru.com
juraganponsel.com
seribuinfounik
infosekarang
usahasekarang
fullsharing
gudangartikel
shareartikel
sharingituindah
kumpulanartikel
beritanasional
pemulablog
thank's for web ini ahahahaha

Tradingview50k said...

The commission toolbox review
The commission toolbox review
The commission toolbox review
The commission toolbox review
The commission toolbox review
The commission toolbox review
The commission toolbox review
The commission toolbox reviewThe commission toolbox review

Ronin92 said...

This is my shopexpressreviews! Online shopping is booming as people find it way too easy and convenient to purchase the products by just sitting at home in front of the computer, put in some information and click a few buttons. However, it’s not that easy to do a business on Amazon, Ebay and sites alike. How to attract customers to your store and How to keep their patronage are always the big questions./
Review Page: http://shopexpressreviews.com/ ?
Bonuses Page: http://shopexpressreviews.com/huge-bonuses/
This is my shopexpressreviews! Online shopping is booming as people find it way too easy and convenient to purchase the products by just sitting at home in front of the computer, put in some information and click a few buttons. However, it’s not that easy to do a business on Amazon, Ebay and sites alike. How to attract customers to your store and How to keep their patronage are always the big questions./
Review Page: http://shopexpressreviews.com/ ?
Bonuses Page: http://shopexpressreviews.com/huge-bonuses/

product launch said...

instaeasy review
have Your Instagram liking, comment and engage automaticlly
instaeasy review
instaeasy review
engaging with audience 24 hours a day instaeasy review
instaeasy review
InstaEasyinstaeasy review
instaeasy review
Luke Maguire
instaeasy review
instagram auto engagement tool
instaeasy review
the worlds leading instagram tool
instaeasy review
Make money made easy
instaeasy review
Thanks for reading

SIM THÀNH ĐẠT said...

thiet ke biet thu

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

thiet ke lau dai

Unknown said...

may ep bun bang tai máy ép bùn máy ép bùn khung bản may ep bun khung ban may ep bun may loc bun may ep thuy luc máy lọc bùn máy ép thủy lực máy ép bùn băng tải máy lọc bùn

ngoaigiaodoan102 said...

chung cư việt đức complex
thiết kế chung cư việt đức complex
giá bán việt đức complex
chung cư việt đức 39 lê văn lương
tiến độ chung cư việt đức complex
chung cu ngoai giao doan
chung cu n02t1 ngoai giao doan
chung cu n01t5 ngoai giao doan
chung cu n03t1 ngoai giao doan

ngoaigiaodoan102 said...

chung cu n02t3 ngoai giao doan
can ho no2t3 ngoai giao doan
chung cu n03t2 ngoai giao doan
can ho no3t2 ngoai giao doan
chung cu n03t3-n03t4 ngoai giao doan
chung cu n03 t5 ngoai giao doan
can ho no3t5 ngoai giao doan
chung cu n04b ngoai giao doan
can ho chung cu no4b ngoai giao doan
chi tiet can ho cong vu ngoai giao doan

Unknown said...
This comment has been removed by the author.
Unknown said...

Gamuda Garden visit into website:
Gamuda City
Gamuda Garden
Chung cư Gamuda The Zen
Nhà liền kề Gamuda
Biệt thự song lập Gamuda
Biệt thự đơn lập Gamuda

Unknown said...

Chào quý khách,
Nga xin gửi đến quý khách bảng giá Toyota Vinh mới nhất. Giá dưới đây là Giá Bán Lẻ Đề Xuất (GBLDX) đã bao gồm Giá trị gia tăng (VAT) 10%. GBLDX không bao gồm các loại thuế và khoảng phí khi đăng kí xe, giá phụ kiện và các chương trình khuyến mãi kèm theo. Đây là bảng niêm yết Toyota Việt Nam nên cập nhật mức giá tốt nhất quý khách liên hệ với 0911 711 588 hoặc điền form báo giá nhanh
Xem giá

Toyota Hiace Động cơ xăng
Trả góp triệu đồng / tháng

Toyota Hiace Động cơ dầu
Trả góp triệu đồng / tháng

Toyota Hilux 2.4G 4×4 MT
Trả góp triệu đồng / tháng

Toyota Hilux 2.4E 4×2 MT
Trả góp triệu đồng / tháng

Toyota Hilux 2.4E 4×2 AT
Trả góp triệu đồng / tháng

Toyota Innova 2.0V
Trả góp triệu đồng / tháng
https://ototoyotavinh.com/xe/toyota-innova

Toyota Innova 2.0E
Trả góp triệu đồng / tháng

Toyota Innova 2.0G
Trả góp triệu đồng / tháng

Toyota Innova Venturer
Trả góp triệu đồng / tháng

Toyota Fortuner 2.4G 4×2
981 triệu
Trả góp triệu đồng / tháng

Toyota Fortuner 2.7V 4×2
1 tỷ 149 triệu
Trả góp triệu đồng / tháng

Toyota Fortuner 2.7V 4×4
Trả góp triệu đồng / tháng

Toyota Camry 2.5G
Trả góp triệu đồng / tháng

Toyota Camry 2.5Q
Trả góp triệu đồng / tháng

Toyota Camry 2.0E
Trả góp triệu đồng / tháng

https://ototoyotavinh.com/xe/toyota-camry

Toyota Corolla Altis 2.0V Sport
905 triệu
Trả góp triệu đồng / tháng

Toyota Corolla Altis 2.0V
864 triệu
Trả góp triệu đồng / tháng

Toyota Corolla Altis 1.8G (CVT)
753 triệu
Trả góp triệu đồng / tháng

Toyota Corolla Altis 1.8E (CVT)
707 triệu
Trả góp triệu đồng / tháng

Toyota Corolla Altis 1.8E (MT)
https://ototoyotavinh.com/xe/toyota-corolla-altis
678 triệu
Trả góp triệu đồng / tháng

Toyota Yaris G CVT
642 triệu
Trả góp triệu đồng / tháng

Toyota Yaris E CVT
592 triệu
Trả góp triệu đồng / tháng
https://ototoyotavinh.com/xe/toyota-yaris

Toyota Vios 1.5G TRD (CVT)
586 triệu
Trả góp triệu đồng / tháng

Toyota Vios 1.5G (CVT)
565 triệu
Trả góp triệu đồng / tháng

Toyota Vios 1.5E (CVT)
535 triệu
Trả góp triệu đồng / tháng

Toyota Vios 1.5E (MT)
515 triệu
Trả góp triệu đồng / tháng
https://ototoyotavinh.com/xe/toyota-vios

ngoaigiaodoan102 said...

chung cu ngoai giao doan
chung cu n01t6 t7 ngoai giao doan
hanjardin ngoai giao doan
chung cu n03 t6 ngoai giao doan
cho thue chung cu ngoai giao doan
cho thue mat bang ngoai giao doan
cho thue biet thu ngoai giao doan
hanjardin ngoai giao doan
chung cu n03t6 ngoai giao doan
du an n03t6 ngoai giao doan

cmtech said...

Please collect more information for your website. I really like your website. Thanks for what you have shared
cửa công nghiệp

datxanhmienbacland said...

Han Jardin Ngoại Giao Đoàn công trình kiến trúc độc đáo nằm tại vị trí trung tâm khu đô thị ngoại giao đoàn, thiết kế căn hộ chung cư Han Jardin Ngoại Giao Đoàn vô cùng hiện đại và thông minh, tận dụng tối đa không gian sử dụng. Quý khách hàng có thể xem đầy đủ thông tin về dự án tại web Đất Xanh Miền Bắc Land

digitals said...

top social bookmarking sites
high da social bookmarking sites
social bookmarking websites
top bookmarking sites
high pr bookmarking sites
free social bookmarking submission sites list
dofollow social bookmarking sites list with high page rank

new social bookmarking sites list
free bookmarking sites

free social bookmarking sites list

sweetheart said...

Best Mumbai Escorts 5000 So Give A Call To Arpita Jain@9004458359
Arpita Jain is the best call young lady escort in Mumbai city serving million of folks. She conveys inside herself much possibility to fulfil the men.

sweetheart said...

Mumbai Escort Service Contact Arpita Jain Soon At 9004458359
Mumbai Escorts Sex is incredibly well-liked. Moreover and relying team having its varied branches spread all over. Our Sex Escort Agency In Mumbai can offer you very best memories. Mumbai Escort Service If you're able to avail all your impassioned pleasure then you only have to be compelled to decision Mumbai. We have got unbroken our line opened 24×7 and you just need
Juhu Escorts
Escort Service In Mumbai
Mumbai Model Escorts

Ayesha Bajaj said...

Diya Roy is a premier escort Service in Guwahati that provides call girl services
or Call Girls in Guwahati hotels at cheap and affordable fixed rates.
Guwahati Call Girls
Call Girls in Guwahati

Anonymous said...

Explore the profiles of guwahati escorts, guwahati call girls, call girls in guwahati and
escorts in guwahati for female companionship in top rated hotels.
Get affordable escort services in guwahati hotels now.
Guwahati call girl
Escorts in Guwahati

Vaishali Verma said...

The charming and attractive youthful Udaipur escort will be available to both the in call and the outcall. Seductive, you can definitely lose your control on my sex body Call / What's App, the time you see me. I'm on board and my hips are certified plane. My relationship organizations are slowly being searched in the city. There are a handful of people you might spot regularly coming to the town of Udaipur to contribute an incredible amount of time to Escort's mind in Udaipur.
Udaipur escort service
udaipur female escorts
call girls service in udaipur
escort service in udaipur
udaipur call girls
udaipur escorts
escorts in udaipur
udaipur russian escorts
udaipur housewife escorts

Ayo Pusing said...

rental mobil terdekat Rental Alphard Bandung