abolfazl abbasi
5 سال پیش توسط abolfazl abbasi مطرح شد
13 پاسخ

ارتباط با api اینستاگرام

سلام من میخواستم ی سری فیلم که که داخل هاست هست رو تو اینستاگرام با استفاده از api اینستاگرام به داخل پیج مورد نظرم ارسال کنم کلاس های که من برای ارتباط با اینستاگرام پیدا کردم همشون نیاز به کامپوزر دارن معمولا هم بیشتر هاستینگ ها دسترسی ssh به کاربر نمیدن کلاسی سراغ دارین که بدون استفاده از کامپوزر بشه با اینستاگرام ارتباط بر قرار کرد


ثبت پرسش جدید
علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 5 سال پیش مطرح شد
1

اگر مشکل نداشتن کامپوزر هست میتونید local نصب کنید و بعد روی سرور آپلود کنید


vahid Mohammadi
@viva.mohammadi 5 سال پیش مطرح شد
1

@abolfazlabbasi

شما باید از گیت هاب نسخه اصلیش (master) رودانلود کنید و تنظیمات مربوط به autoload این کتابخونه رو درست کنید
این دقیقا کاریه که composer میکنه


علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 5 سال پیش مطرح شد
1

اگر مشکل نداشتن کامپوزر هست میتونید local نصب کنید و بعد روی سرور آپلود کنید


امیر اردکانی
تخصص : طراح و برنامه نویس وب
@AmirArdakani 5 سال پیش آپدیت شد
1

بهترین کتابخونه اینه در زمینه کار با اینستاگرام که حتی nextpost هم ازش استفاده کرده

https://github.com/mgp25/Instagram-API

اینکه میگین دسترسی به ssh میخواد فکر نکنم اینطور باشه طبق گفته دوست عزیز @ali.bayat پیش برین , چون مثه لاراول نیست که مدام بخواین دستورات artisan رو اجرا کنید شما یکبار با دستور composer require بسته رو نصب میکنید و ازش استفاده میکنید طبق داکیومنت کتابخونه الان این مثال برای آپلود ویدیو :

<?php

set_time_limit(0);
date_default_timezone_set('UTC');

require __DIR__.'/../vendor/autoload.php';

/////// CONFIG ///////
$username = '';
$password = '';
$debug = true;
$truncatedDebug = false;
//////////////////////

/////// MEDIA ////////
$videoFilename = '';
$captionText = '';
//////////////////////

$ig = new InstagramAPIInstagram($debug, $truncatedDebug);

try {
    $ig->login($username, $password);
} catch (Exception $e) {
    echo 'Something went wrong: '.$e->getMessage()."
";
    exit(0);
}

try {
    $video = new InstagramAPIMediaVideoInstagramVideo($videoFilename);
    $ig->timeline->uploadVideo($video->getFile(), ['caption' => $captionText]);
} catch (Exception $e) {
    echo 'Something went wrong: '.$e->getMessage()."
";
}

abolfazl abbasi
@abolfazlabbasi 5 سال پیش آپدیت شد
0

@ali.bayat
من الان نصب کردم با کامپوزر فایل هارو داخل هاست اپلود کنم و از کد زیر استفاده کنم؟
‍‍ ‍‍‍```
require DIR.'/../vendor/autoload.php';

$ig = new InstagramAPIInstagram();```


abolfazl abbasi
@abolfazlabbasi 5 سال پیش مطرح شد
0

@AmirArdakani

Instagram-API Warning!
Can I run this library via a website?
No. Don't do it. You cannot safely use this or any other 3rd party Instagram libraries directly via a website!

This library (and all other 3rd party reverse engineered Instagram libraries), is made for command line usage in a terminal by running the script like a program (such as php yourscript.php). We do not recommend running this library via a web browser! Because browsers will terminate the PHP process as soon as the user closes their connection to the page (closes the tab, or presses "Stop loading page"), which means that your script can terminate at any moment. This library is not a webpage! It is an Instagram for Android application emulator. It emulates an application. Not a webpage. You cannot just randomly kill this library in the middle of work! (You might kill it while it's writing to disk or calling some important APIs!)

And furthermore, if it's used on a webpage then it must waste time logging in to Instagram every time the user refreshes the webpage, since each page load would start a new script (meaning "a new Instagram app emulator") from scratch. And there are also massive risks about concurrent access from multiple web requests to a single user account which can corrupt your settings-storage or cookies. So we really, really do not recommend running this library via a browser! It's a very bad idea!

Instead, you should run your Instagram app emulator script as a permanent 24/7 process, and make it dump data to a database which your regular website reads from, or make some kind of permanent localhost daemon that can listen locally on the server and receive queries on a port (localhost queries from the main website's scripts), and then performing those queries via the API and responding to the website script with something like JSON or with serialized src/Response/ objects, which the website script then transforms for final display to the user.

You must also be sure that your permanent process periodically calls login() inside your 24/7 PHP process, to emulate the Instagram for Android application being closed/opened and refreshing itself (like a real user would do). Otherwise it will soon get banned or silently limited as a "detected bot" by Instagram due to never calling login. Preferably use the same refresh ranges we use by default, so that you refresh login() within a random range between every 30 minutes, or at max every 6 hours.

So, to recap: Make your "Instagram application" part a permanent process, and then make your webpage interact with that permanent process or an intermediary database in some way. That's the proper architecture system if you want to use this library online! Imagine it like your website talking to a phone and telling its permanently running Instagram app to do things. That's the proper design and that's how you have to think about things.

Never forget this fact: This library (and all other 3rd party libraries) is an Android application emulator. It is not a website and will never be able to become a website (because the Android application is not a website!). Therefore, we will never give support to anyone who decides to use the library directly inside a webpage. If you do that, it's at your own risk! It is a really terrible and unsupported idea!

If you truly want to enable incorrect website usage by directly embedding this application emulator library in your page, then you can do that AT YOUR OWN RISK by setting the following flag before you create the Instagram() object:

\InstagramAPI\Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;


علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 5 سال پیش مطرح شد
0

@abolfazlabbasi

بله در فایل PHP که میخواهید از Api اینستاگرام استفاده کنید, ابتدا کامپوزر رو لود کنید:

require __DIR__.'/../vendor/autoload.php';

فقط قبل از آپلود فولدر vendor یک بار دستور زیر رو اجرا کنید:

composer dump-autoload

امیر اردکانی
تخصص : طراح و برنامه نویس وب
@AmirArdakani 5 سال پیش مطرح شد
0

@abolfazlabbasi

\InstagramAPI\Instagram::$allowDangerousWebUsageAtMyOwnRisk = true;

اینو قرار بدید اون ارور رفع میشه


abolfazl abbasi
@abolfazlabbasi 5 سال پیش مطرح شد
0

@AmirArdakani
@ali.bayat

متاسفانه مشکل هنوز پا برجاست


علی بیات
تخصص : توسعه دهنده ارشد وب
@ali.bayat 5 سال پیش مطرح شد
1

این خطا داره میگه که این کتابخونه در اصل برای استفاده در کامند لاین ساخته شده و نه برای استفاده در مرورگر


امیر اردکانی
تخصص : طراح و برنامه نویس وب
@AmirArdakani 5 سال پیش آپدیت شد
0

من دارم از این کد استفاده میکنم سمت مرورگر بدون مشکل کار میکنه :

<?php
ini_set("display_errors", 1);
require __DIR__.'/vendor/autoload.php';

InstagramAPIInstagram::$allowDangerousWebUsageAtMyOwnRisk = true;

define("ROOTPATH", dirname(__FILE__));

// Path to app folder.
define("APPPATH", ROOTPATH."/");
define("SESSIONS_PATH", APPPATH . "/sessions");

$username = '';
$password = '';
$debug = false;
$truncatedDebug = false;
$storageConfig = [
    "storage" => "file",
    "basefolder" => SESSIONS_PATH."/".$username."/",
];

$Instagram = new InstagramAPIInstagram($debug, $truncatedDebug,$storageConfig);
try {
//    $login = $Instagram->login($username, $password);
    $Instagram->_setUser($username, $password);

    $userId = $Instagram->people->getUserIdForName($username);
    $res = $Instagram->people->getInfoById($userId);
//    $text = 'مرجع کلیپ';
//    $user = $Instagram->account->setBiography($text);
//    print_r($user);
} catch (Exception $e) {
    echo 'Something went wrong: '.$e->getMessage()."
";
}

حتی از طریق این کتابخونه یه یک آی دی دیگه هم دایرکت ارسال کردم به خوبی دریافت شده اون دایرکت.


Sajad
@s2m72 5 سال پیش مطرح شد
0

سلام
آقای @AmirArdakani من هم از این پکیج استفاده کردم ولی یه مشکلی دارم موقع لاگین خطای زیر رو بر می گردونه:
InstagramAPI\Response\TimelineFeedResponse: Consent required.

میدونید مشکلش چیه و چطوری رفع میشه؟
باتشکر


Salman Irani
تخصص : برنامه نویس
@irani.salman 5 سال پیش مطرح شد
0

دوستی که میخواد در وب از این کتابخونه استفاده کنه در پوشه src/instagram.php
public static $allowDangerousWebUsageAtMyOwnRisk = false;
را true کنه مشکلش حل میشه


Nasser Zarre
تخصص : Laravel-Jquery-PHP-MYSQL
@nassi125zarri 4 سال پیش مطرح شد
0

عرض سلام و خسته نباشید خدمت اساتید عزیز

من میخام از اینستاگرام اطلاعات یوزرها رو در بیارم ذخیره کنم.
برای اینکار از این آدرس استفاده میکردم :
https://www.instagram.com/{userName}/?__a=1
و خروجی چنین دستوری بصورت json همه نیاز رو برطرف میکرد در وحله اول کار.

ظاهرا دیگه این روش جواب نمیده و باید حتما لاگین باشی تا اطلاعات رو بهت نشون بده با روش بالا.

رفتم توی فیسبوک ثبتنام کردم که دسترسی استفاده از API رو بگیرم . خیلی مزخرف و پیچیده بود اما با نگاه به ویدیوهای آموزشی اینکارو انجام دادم . حالا در پنلم AccessToken هم دریافت کردم ولی هرکار میکنم ارور نامعتبر بودن میده . اینم ادرس مورد استفاده با اکسس توکنم :

https://api.instagram.com/v1/users/search?q=kkkk&client_id=IGQVJXVFpYalFwWUF5MEEzbl95Sno2aHMtVUZAoWnpTZAVNka1dIN054OTNaVi10MUlTV3dLWWZAaSjkyU05DcElwdzBJcGV4QVVxVlVweGlLYjgtVVVacEhJaU5OSjMzRUhjU182X0E5SENjOENOTjN3VgZDZD

و خطایی که میده. این هست :

{"meta": {"code": 400, "error_type": "OAuthAccessTokenException", "error_message": "The access_token provided is invalid."}}

کسی از دوستان اطلاعی داره از روش استفاده یا علت این خطا . هرجی سرچ کردم راه حلی پیدا نکردم و متاسفانه خود فیسبوک مزخرف هم اطلاعات درستی نداده از این مشکل. اگر اساتید عزیز بلد هستن ممنون میشم راهنمایی کنید.

@irani.salman
@AmirArdakani
@ali.bayat


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام