解码instagram回复(php)

时间:2013-11-14 15:19:36

标签: php instagram json

我正试图从Instagram上的热门帖子中获取信息,当我在api响应中使用var_dump()时,它会填充一个包含我想要的信息的字符串,当我尝试使用{ {1}}它返回null,当我检查json_decode()时,我得到json_last_error()

这是我的.php文件

Malformed UTF-8 characters, possibly incorrectly encoded

2 个答案:

答案 0 :(得分:0)

我试试这个:

$response = iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($response));
$json = json_decode($response);

或不转换:

$json = json_decode(utf8_encode($response));

根据评论编辑:

我注意到json中有一些html实体(例如,smileys):

   html_entity_decode($response);

答案 1 :(得分:0)

我遇到了同样的问题,因为我在某个地方使用了默认的<?php /** * Laravel - A PHP Framework For Web Artisans * * @package Laravel * @author Taylor Otwell <taylor@laravel.com> */ define('LARAVEL_START', microtime(true)); require __DIR__.'/../root/vendor/autoload.php'; $app = require_once __DIR__.'/../root/bootstrap/app.php'; // set the public path to this directory $app->bind('path.public', function() { return __DIR__; }); $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response); 模块,然后将其替换为substr(),现在可以正常使用了