Php скрипт для инстаграм

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

PHP SDK for Instagram API

License

Andreyco/Instagram-for-PHP

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.markdown

instagram-logo-400x400

A PHP wrapper for the Instagram API. Feedback or bug reports are appreciated.

To use the Instagram API with OAuth you have to register yourself as developer at the Instagram Developer Platform and set up an App. Take a look at the uri guidlines before registering a redirect URI.

Please note that Instagram mainly refers to »Clients« instead of »Apps«. So »Client ID« and »Client Secret« are the same as »App Key« and »App Secret«.

A good place to get started is the example App.

This package offers Laravel support out of the box. These steps are required to setup the package.

Installation

composer require andreyco/instagram

Add Service provider and register Facade

'providers' => array( // . Andreyco\Instagram\Support\Laravel\ServiceProvider\Instagram::class, // . ), 'aliases' => array( // . 'Instagram' => Andreyco\Instagram\Support\Laravel\Facade\Instagram::class, // . ),

Configuration

// Pushlish configuration file. php artisan vendor:publish --provider pl-s">Andreyco\Instagram\Support\Laravel\ServiceProvider\Instagram" // Edit previously created `config/instagram.php` file return [ 'clientId' => '. ', 'clientSecret' => '. ', 'redirectUri' => '. ', 'scope' => ['basic'], ]

In Laravel application, you can access library by simply using Instagram facade, e.g.

Читайте также:  Html button text height

For usage in pure PHP, you have to create instance of class.

$instagram = new Andreyco\Instagram\Client($config); $instagram->getLoginUrl()
 // Generate and redirect to login URL. $url = Instagram::getLoginUrl(); // After allowing to access your profile, grab authorization *code* when redirected back to your page. $code = $_GET['code']; $data = Instagram::getOAuthToken($code); // Now, you have access to authentication token and user profile echo 'Your username is: ' . $data->user->username; echo 'Your access token is: ' . $data->access_token; ?>
 // Set user access token Instagram::setAccessToken($accessToken); // Get all user likes $likes = Instagram::getUserLikes(); // Take a look at the API response echo '
'; print_r($likes); echo '
'; ?>

new Instagram($config: Array|String);

array if you want to authenticate a user and access its data:

new Instagram([ 'apiKey' => 'YOUR_APP_KEY', 'apiSecret' => 'YOUR_APP_SECRET', 'apiCallback' => 'YOUR_APP_CALLBACK' ]);

string if you only want to access public data:

new Instagram('YOUR_APP_KEY');

getLoginUrl($scope: [Array], $state: [string])

getLoginUrl(['basic', 'likes'], 'uMFYKG5u6v');

Optional scope parameters: To find out more about Scopes, please visit https://www.instagram.com/developer/authorization/

true : Return only the OAuth token false [default] : Returns OAuth token and profile data of the authenticated user

Set access token, for further method calls: setAccessToken($token)

Return access token, if you want to store it for later usage: getAccessToken()

  • getUser()
  • getUser($id)
  • searchUser($name, )
  • getUserMedia($id, )
  • getUserLikes()
  • getUserMedia(, )
    • if an $id isn't defined, or equals to self it returns the media of the logged in user
    • getSelfFollows()
    • getSelfFollowedBy()
    • getUserRelationship($id)
    • modifyRelationship($action, $user)
      • $action : Action command (follow / unfollow / block / unblock / approve / deny)
      • $user : Target user id
       // Follow the user with the ID 1574083 $instagram->modifyRelationship('follow', 1574083); ?>

      Please note that the modifyRelationship() method requires the relationships scope.

      • getMedia($id)
      • searchMedia($lat, $lng, , , )
        • $lat and $lng are coordinates and have to be floats like: 48.145441892290336 , 11.568603515625
        • $distance Radial distance in meter (default is 1km = 1000, max. is 5km = 5000)
        • $minTimestamp All media returned will be taken later than this timestamp (default: 5 days ago)
        • $maxTimestamp All media returned will be taken earlier than this timestamp (default: now)
        • getMediaComments($id)
        • addMediaComment($id, $text)
          • restricted access: please email apidevelopers[at]instagram.com for access
          • the comment must be authored by the authenticated user

          Please note that the authenticated methods require the comments scope.

          All <. >parameters are optional. If the limit is undefined, all available results will be returned.

          Instagram entries are marked with a type attribute ( image or video ), that allows you to identify videos.

          An example of how to embed Instagram videos by using Video.js, can be found in the /example folder.

          Please note: Instagram currently doesn't allow to filter videos.

          In order to prevent that your access tokens gets stolen, Instagram recommends to sign your requests with a hash of your API secret, the called endpoint and parameters.

          1. Activate "Enforce Signed Header" in your Instagram client settings.
          2. Enable the signed-requests in your Instagram class:
          $instagram->setEnforceSignedRequests(true);

          Each endpoint has a maximum range of results, so increasing the limit parameter above the limit won't help (e.g. getUserMedia() has a limit of 90).

          That's the point where the "pagination" feature comes into play. Simply pass an object into the pagination() method and receive your next dataset:

           $photos = $instagram->getTagMedia('kitten'); $result = $instagram->pagination($photos); ?>

          Iteration with do-while loop.

          Samples for redirect URLs

          Registered Redirect URI Redirect URI sent to /authorize Valid?
          http://yourcallback.com/ http://yourcallback.com/ yes
          http://yourcallback.com/ http://yourcallback.com/?this=that yes
          http://yourcallback.com/?this=that http://yourcallback.com/ no
          http://yourcallback.com/?this=that http://yourcallback.com/?this=that&another=true yes
          http://yourcallback.com/?this=that http://yourcallback.com/?another=true&this=that no
          http://yourcallback.com/callback http://yourcallback.com/ no
          http://yourcallback.com/callback http://yourcallback.com/callback/?type=mobile yes

          If you need further information about an endpoint, take a look at the Instagram API docs.

          Image

          This example project, located in the example/ folder, helps you to get started. The code is well documented and takes you through all required steps of the OAuth2 process. Credit for the awesome Instagram icons goes to Ricardo de Zoete Pro.

          More examples and tutorials:

          Let me know if you have to share a code example, too.

          Copyright (c) 2014 - Andrej Badin Released under the BSD License.

          Instagram-PHP-API contains code taken from Christian Metz's Instagram-PHP-API, also licensed under BSD License.

          About

          PHP SDK for Instagram API

          Источник

          Saved searches

          Use saved searches to filter your results more quickly

          You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

          A PHP script to go in live Instagram with any streaming program that supports RTMP!

          License

          zProAle/InstaLive-PHP

          This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

          Name already in use

          A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

          Sign In Required

          Please sign in to use Codespaces.

          Launching GitHub Desktop

          If nothing happens, download GitHub Desktop and try again.

          Launching GitHub Desktop

          If nothing happens, download GitHub Desktop and try again.

          Launching Xcode

          If nothing happens, download Xcode and try again.

          Launching Visual Studio Code

          Your codespace will open once ready.

          There was a problem preparing your codespace, please try again.

          Latest commit

          Git stats

          Files

          Failed to load latest commit information.

          README.md

          Thanks to mgp25 for Instagram-API. Thanks to machacker16 for the live script part.

          A PHP script to go in live Instagramam with any streaming program that supports RTMP!

          • Install PHP
          • Install Composer
          • run composer install into directory
          • set username and password inside off config.php
          • run the script with live.php
          • copy Stream-URL and Stream-Key and paste them into your streaming software.
          • Go to the "Stream" section of your OBS Settings
          • Set "Stream Type" to "Custom Streaming Server"
          • Set the "URL" field to the stream url you got from the script
          • Set the "Stream key" field to the stream key you got from the script
          • Make Sure "Use Authentication" is unchecked and press "OK"
          • Start Streaming in OBS
          • To stop streaming, run the "stop" command in your terminal and then press "Stop Streaming" in OBS
          • Note: To emulate the exact content being sent to Instagram, set your OBS canvas size to 720x1280. This can be done by going to Settings->Video and editing Base Canvas Resolution to "720x1280".
          • You will NOT use this API for marketing purposes (spam, botting, harassment, massive bulk messaging. ).
          • We do NOT give support to anyone who wants to use this API to send spam or commit other crimes.
          • We reserve the right to block any user of this repository that does not meet these conditions.

          This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.

          About

          A PHP script to go in live Instagram with any streaming program that supports RTMP!

          Источник

          Saved searches

          Use saved searches to filter your results more quickly

          You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

          License

          icnaves/InstaPosting

          This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

          Name already in use

          A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

          Sign In Required

          Please sign in to use Codespaces.

          Launching GitHub Desktop

          If nothing happens, download GitHub Desktop and try again.

          Launching GitHub Desktop

          If nothing happens, download GitHub Desktop and try again.

          Launching Xcode

          If nothing happens, download Xcode and try again.

          Launching Visual Studio Code

          Your codespace will open once ready.

          There was a problem preparing your codespace, please try again.

          Latest commit

          Git stats

          Files

          Failed to load latest commit information.

          README.md

          PHP скрипт для автоматического постинга картинок в соцсеть instagram.com всего в два шага.

          • Авторизация в сервисе
          • Копирование картинки по url в папку uploads
          • Постинг в instagram.com
          • Удаление картинки из uploads

          Так как скрипт копирует картинку на сервер, необходимо создать папку uploads, ей и корневой папке InstaPosting выставить права 777(на запись)

          InstaPosting работает только с расширением *.jpg

          $InstaPosting = new InstaPosting('username', 'password');
          $InstaPosting->PostImage('http://www.ronaldrestituyo.com/wp-content/uploads/2016/10/Instagram_Logo1.jpg', 'Привет, Instagram');

          Источник

Оцените статью