English 中文(简体)
1. 与姓名一起工作。
原标题:Working with Name.com API (PHP)
  • 时间:2012-01-12 13:15:03
  •  标签:
  • php
  • api
  • class

我现在用的是姓名.com API,他们有文件解释如何获得细节。

我已经做了一切,但我可以照抄结果。

我已做过var(var)。

object(stdClass)#4 (2) { 
    ["result"]=> object(stdClass)#5 (2) { 
        ["code"]=> int(100) ["message"]=> string(18) "Command Successful" 
    } 
    ["domains"]=> object(stdClass)#6 (8) { 
        ["mynewdomain.mobi"]=> object(stdClass)#7 (5) { 
            ["avail"]=> bool(true) 
            ["tld"]=> string(4) "mobi" 
            ["price"]=> string(4) "8.99" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(false) 
        } 
        ["mynewdomain.net"]=> object(stdClass)#8 (5) { 
            ["avail"]=> bool(false) 
            ["tld"]=> string(3) "net" 
            ["price"]=> string(5) "49.95"
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(true) 
        } 
        ["mynewdomain.org"]=> object(stdClass)#9 (5) { 
            ["avail"]=> bool(true) 
            ["tld"]=> string(3) "org" 
            ["price"]=> string(4) "9.99" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(false) 
        } 
        ["mynewdomain.info"]=> object(stdClass)#10 (5) { 
            ["avail"]=> bool(true) 
            ["tld"]=> string(4) "info" 
            ["price"]=> string(4) "3.99" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(false) 
        } 
        ["mynewdomain.com"]=> object(stdClass)#11 (5) { 
            ["avail"]=> bool(false) 
            ["tld"]=> string(3) "com" 
            ["price"]=> string(5) "49.95" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(true) 
        } 
        ["mynewdomain.biz"]=> object(stdClass)#12 (5) { 
            ["avail"]=> bool(false) 
            ["tld"]=> string(3) "biz" 
            ["price"]=> string(5) "29.95" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(true) 
        } 
        ["mynewdomain.me"]=> object(stdClass)#13 (5) { 
            ["avail"]=> bool(false) 
            ["tld"]=> string(2) "me" 
            ["price"]=> string(5) "49.95" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(true) 
        } 
        ["mynewdomain.tv"]=> object(stdClass)#14 (5) { 
            ["avail"]=> bool(false) 
            ["tld"]=> string(2) "tv" 
            ["price"]=> string(5) "49.95" 
            ["premium"]=> bool(false) 
            ["backorder"]=> bool(true) 
        }
    } 
}

and this is another short result for listing domains:

object(stdClass)#4 (2) { 
    ["result"]=> object(stdClass)#5 (2) { 
        ["code"]=> int(100) 
        ["message"]=> string(18) "Command Successful" 
    } 
    ["domains"]=> array(0) { } 
}

我尝试如下:

  • <代码>echo$response->domains

  • echo $response[ domains ]

但实际上,我无法工作。 谁能帮助我?

提前感谢,

最佳回答

看像你那样,正找回一批物体,因此,你需要用 $子(response->domains)回收。 我把这推向一个新的老鼠,以方便处理:

$domains = &$response->domains;

foreach($domains as $key => $value) {
  echo $key.":
";
  foreach($value as $a => $b) {
    if($b === true) $b =  yes ;
    if($b === false) $b =  no ;
    echo $a.": ".$b."
";
  }
}

注:response->result ONLY载有送来服务器的指挥结果。 检查,确保你出现错误,但意图是预期你的数据会在那里。

问题回答

发出信息:

echo $response->result->message;

获取域名:

foreach ($response->domains as $domainName => $domainData)
{

    echo $domainName.": available-".$domainData->avail."; price - ".$domainData->price;

}

在我看来,所有东西似乎都列在“<>result上”。 为此:

echo $response["result"]["domains"];




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签