Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google Goggles API在PHP中的解决问题_Php_.net_Arrays_Google Goggles - Fatal编程技术网

Google Goggles API在PHP中的解决问题

Google Goggles API在PHP中的解决问题,php,.net,arrays,google-goggles,Php,.net,Arrays,Google Goggles,我一整天都在为下面的事情烦恼: 我正试图通过以下博文中的PHP移植代码向Google Goggles发送手动请求: 最初的博文显然是用.NET编写的工作代码,但我的平台是PHP。我的密码是: $googleID = substr(md5(rand()), 0, 16); /* */ $url = 'http://www.google.com/goggles/container_proto?cssid=' . $googleID; // $url = 'http://www.goog

我一整天都在为下面的事情烦恼:

我正试图通过以下博文中的PHP移植代码向Google Goggles发送手动请求:

最初的博文显然是用.NET编写的工作代码,但我的平台是PHP。我的密码是:

$googleID = substr(md5(rand()), 0, 16); 

  /* */
  $url = 'http://www.google.com/goggles/container_proto?cssid=' . $googleID;
//  $url = 'http://www.google.com/goggles/container_proto?cssid=';


//  $googleCodes = array(0x22,0x00,0x62,0x3C,0x0A,0x13,0x22,0x02,0x65,0x6E,0xBA,0xD3,0xF0,0x3B,0x0A,0x08,0x01,0x10,0x01,0x28,0x01,0x30,0x00,0x38,0x01,0x12,0x1D,0x0A,0x09,0x69,0x50,0x68,0x6F,0x6E,0x65,0x20,0x4F,0x53,0x12,0x03,0x34,0x2E,0x31,0x1A,0x00,0x22,0x09,0x69,0x50,0x68,0x6F,0x6E,0x65,0x33,0x47,0x53,0x1A,0x02,0x08,0x02,0x22,0x02,0x08,0x01);
  $googleCodes = array(34,0,98,60,10,19,34,2,101,110,186,211,240,59,10,8,1,16,1,40,1,48,0,56,1,18,29,10,9,105,80,104,111,110,101,32,79,83,18,3,52,46,49,26,0,34,9,105,80,104,111,110,101,51,71,83,26,2,8,2,34,2,8,1);

  $handle = curl_init($url);
  curl_setopt($handle, CURLOPT_POST, true);
  curl_setopt($handle, CURLOPT_POSTFIELDS, array("CssidPostBody" => implode("",$googleCodes)));
  curl_setopt($handle, CURLOPT_HTTPHEADER, array("Content-Type: application/x-protobuffer",
                                                 "Pragma: no-cache"));
  $response = curl_exec($handle);
  /* */

  print_r($response);
我不断从谷歌得到以下回复:

"Unparseable Container Request"
我认为我的问题在于
$googleCodes
的格式。原文有以下内容:

private static byte[] CssidPostBody = new byte[] { 34, 0, 98, 60, 10, 19, 34,
            2, 101, 110, 186, 211, 240, 59, 10, 8, 1, 16, 1, 40, 1, 48, 0, 56, 1, 18,
            29, 10, 9, 105, 80, 104, 111, 110, 101, 32, 79, 83, 18, 3, 52, 46, 49, 
            26, 0, 34, 9, 105, 80, 104, 111, 110, 101, 51, 71, 83, 26, 2, 8, 2, 34,
            2, 8, 1 };
我意识到这是一个可能非常独特的问题,但我希望有.NET字节数组经验的人能为我指明正确的方向

$googleCodes = array(34,0,98,60,10,19,34,2,101,110,186,211,240,59,10,8,1,16,1,40,1,48,0,56,1,18,29,10,9,105,80,104,111,110,101,32,79,83,18,3,52,46,49,26,0,34,9,105,80,104,111,110,101,51,71,83,26,2,8,2,34,2,8,1);

foreach ($googleCodes as $n=>$char) { $googleCodes[$n] = chr($char); }
我认为这些是字符的代码,我怀疑它们是以二进制形式发送的。要么这样,要么它们应该是零填充的。你能用外语提供原始方法的链接吗?我们只是想模仿他们的方法。我认为你们的数字是一致的,所以这是一个所需格式的问题


我认为这些是字符的代码,我怀疑它们是以二进制形式发送的。要么这样,要么它们应该是零填充的。你能用外语提供原始方法的链接吗?我们只是想模仿他们的方法。我认为你们的数字是一致的,所以这是一个关于所需格式的问题。

谢谢您的回复。原始代码位于:感谢您的回复。原始代码位于: