2012-09-28 24 views
0

我必須使用perl腳本才能與iOS上的App Purchase中的verifReceipt接口。 我也使用phoneGap 1.5.0使用perl腳本的Verif收據

1 /當我嘗試使用外部url不起作用。 2 /我嘗試在phonegap html頁面和itunes之間使用perl腳本接口。 我不明白如何發送數據。我試試這個:

$val contains JSON object with receiptvalue and password, receiving from phonegap. 

my %transformfields = (
      "receipt-data"  => $val, 
      ); 

my $ua = LWP::UserAgent->new; 

my $req = POST($urlsend, 
    Content_Type => 'application/json ; charset=UTF-8', 
    Content => \%transformfields, 
    #Content => $val, 
    ); 



my $res = $ua->request($req); 

我一直這個錯誤:21002顯示java.lang.NullPointerException 我不明白這是怎麼可能用perl腳本發送數據。

+0

我很困惑你的問題。你使用PhoneGap來打你的服務器並運行Perl腳本嗎?我相信你的第一個問題涉及到在PhoneGap中打外部URL。如果它不適合您,請查看白名單上的文檔:http://docs.phonegap.com/en/2.1.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide –

+0

白名單不適用於phonegap 1.5。 0,我添加iTunes網址,但沒有。我必須使用這個版本。 – Ben

+0

我必須在phonegap頁面和itunes之間使用cgi腳本。 – Ben

回答

0

我有問題與json編碼和理解我如何從phonegap插件接收數據。

尋求幫助: Phongap插件在Base64中返回transactionReceipt。 也不要在Base64中編碼密碼。

my %transformfields = ("receipt-data" => $val , "password" => $sharedsecretpass) ; 
my $jsonval = encode_json (\%transformfields); 

print "Content-Type: text/html \n\n"; 

#my $urlsend="https://buy.itunes.apple.com/verifyReceipt" ; 
my $urlsend="https://sandbox.itunes.apple.com/verifyReceipt" ; 

my $req = POST($urlsend, 
    Content_Type => 'application/x-www-form-urlencoded ; charset=utf-8', 
    Content => $jsonval, 
    ); 

my $ua = LWP::UserAgent->new; 
my $res = $ua->request($req); 

if ($res->is_success) 
{ 
    #print "cgi Content : " . $res->content . "<br />\n"; 
    my $retour = decode_json($res->content); 
    if ($retour->{'status'} eq "0") 
    { 
      print "--OK--<br />\n"; 
      print $retour->{receipt}->{product_id} . "<br />"; 
      print $retour->{receipt}->{transaction_id} . "<br />"; 
      print $retour->{receipt}->{purchase_date} . "<br />"; 
      print $retour->{receipt}->{expires_date} . "<br />"; 

      #$res->content 
    }