PHP Instagram友谊/创建/错误

PHP Instagram友谊/创建/错误,php,instagram,instagram-api,Php,Instagram,Instagram Api,我试图在Instagram中建立友谊/创建/运行,但出现了一些错误 帐户/登录功能正在运行 友谊/创建错误:“请更新您的Instagram应用程序以继续以下内容。” ==instagram.php=== function SendRequest($url, $post, $post_data, $user_agent, $cookies) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://instagram.com/api/

我试图在Instagram中建立友谊/创建/运行,但出现了一些错误

帐户/登录功能正在运行

友谊/创建错误:“请更新您的Instagram应用程序以继续以下内容。”

==instagram.php===

function SendRequest($url, $post, $post_data, $user_agent, $cookies) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://instagram.com/api/v1/'.$url);
/*
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
*/
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

if($post) {
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}

if($cookies) {
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');            
} else {
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
}

$response = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array($http, $response);
}
function GenerateGuid() {
 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', 
        mt_rand(0, 65535), 
        mt_rand(0, 65535), 
        mt_rand(0, 65535), 
        mt_rand(16384, 20479), 
        mt_rand(32768, 49151), 
        mt_rand(0, 65535), 
        mt_rand(0, 65535), 
        mt_rand(0, 65535));
}
function GenerateSignature($data) {
 return hash_hmac('sha256', $data, '25eace5393646842f0d0c3fb2ac7d3cfa15c052436ee86b5406a8433f54d24a5');
}

您正在尝试使用Instagram使用条款不允许的私有API,因此只有在那里工作的人知道这里缺少什么

有一些公共API可以实现您希望在此处执行的操作:

修改此行:

$data = '{"device_id":"'.$device_id.'","guid":"'.$guid.'","device_timestamp":"'.time().'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
成为

$data = '{"user_id":"'.$user_id.'","device_id":"'.$device_id.'","guid":"'.$guid.'","device_timestamp":"'.time().'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
您错过了请求中的
user\u id
参数。

更改此行

$data ='{"device_id":"'.$device_id.'","guid":"'.$guid.'","username":"'.$username.'","password":"'.$password.'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
SendRequest('friendships/create/29180689', true, $new_data, $agent, true);


换一条线

$data ='{"device_id":"'.$device_id.'","guid":"'.$guid.'","username":"'.$username.'","password":"'.$password.'","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}';
SendRequest('friendships/create/29180689', true, $new_data, $agent, true);


我的应用程序是新的。因此,我无法添加关系范围。您知道新应用程序的解决方案吗?您必须提交应用程序以供审阅,然后才能使用关系范围。afaik没有其他解决方法。您找到解决方法了吗?
$user\u id
是否与
$username
相同?
SendRequest('friendships/create/29180689/', true, $new_data, $agent, true);