2016-04-14 16 views
0

Ich bin neu in PHP, ich entwickle Android zu PHP Web Services, die in lokalen Host funktioniert. Ich möchte meine app machen leben so lud ich meine PHP-Dateien in byethost17.com in Browser, funktioniert es gut Rückkehr json aber wenn ich meine app laufen seine ShowString kann nicht in JSON konvertieren

org.json.JSONException: Value script of type java.lang.String cannot be converted to JSONObject` 

Der Code funktioniert mit json von lokalen Host-Parsing, die Problem ist von der kostenlosen Hosting-Website. Was ist eine Lösung? Gibt es gute kostenlose Webhosting-Seiten? 100% kostenlos???

org.json.JSONException: Value <html><body><script of type 
    java.lang.String cannot be converted to JSONObject 
at org.json.JSON.typeMismatch(JSON.java:111) 
at org.json.JSONObject.<init>(JSONObject.java:160) 
    at org.json.JSONObject.<init>(JSONObject.java:173) 






     this is result from browser when hit same url 

    {"data":[{"Category": 
{"Category_ID":"3","Category_name":"Camera","Category_image": 
"upload\/images\/7089-2015-07-09.png"}},{"Category": 
{"Category_ID":"9","Category_name":"Cars", 
"Category_image":"upload\/images\/7789-2015-07-09.png"}},{"Category": 
{"Category_ID":"4","Category_name":"Clothes", 
"Category_image":"upload\/images\/9350-2015-07-09.png"}},{"Category": 
{"Category_ID":"1","Category_name":"Computer", 
    "Category_image":"upload\/images\/1843-2015-07-09.png"}},{"Category": 
{"Category_ID":"7","Category_name":"Music", 
"Category_image":"upload\/images\/8666-2015-07-09.png"}},{"Category": 
{"Category_ID":"5","Category_name":"Other", 
"Category_image":"upload\/images\/6260-2015-07-09.png"}},{"Category": 
{"Category_ID":"2","Category_name":"Smartphone", 

"Category_image":"upload\/images\/3025-2015-07-09.png"}},{"Category": 
{"Category_ID":"8","Category_name":"Sports", 

    "Category_image":"upload\/images\/5354-2015-07-09.png"}}, 

{"Category":{"Category_ID":"10","Category_name":"waqas 
Company","Category_image":"upload\/images\/9853-2016-04-11.jpg"}}]} 
+0

W Hat String versucht, in JSON zu konvertieren? –

+0

seine Online-Shop-Produktdaten Ich fand diese Qrstion ähnlich wie mein Problem http://StackOverflow.com/Questions/33439515/Problems-in-Parse-Com-PHP-Hosting –

+0

kann mir jemand sagen, kostenlos Hosting-Websites, die mir richtig geben json ???????? –

Antwort

0

Die JSON-String Sie beginnt mit einem JSON Array zeigen kein JSON-Objekt, versuchen Sie es in ein Array zu analysieren, anstatt

0

Sie benötigen Text auf der Seite zu bekommen, nicht Quelle.

Da in der Quelle, setzen die freien Hosts ihre Werbepartner.

Also, wenn Sie bekommen

{"data": "stuff"} 

In Seite Körper würde die Quelle so etwas wie dieses:

<html><head> 
    <script> 
     /** affliate code **/ 
    </script> 
    </head> 
    <body> 
     <span>{"data": "stuff"}</span> 
    </body> 
</html> 

Ich hoffe, Sie verstehen ...

(auch überprüfen, die Rückgabewert Ihrer Seitenquelle vor dem Parsen zu JSON)

Verwandte Themen