Git Product home page Git Product logo

mozapiv2's Introduction

Moz Api V2 - PHP Library

MozAPIV2-PHP is an open source PHP library to get query data out of Moz's API v2.

MozAPIV2-PHP is used to retrieve information out of Moz's API such as Anchor Text Metrics, Final Redirect, Global Top Pages, Global Top Root Domains, Index Meta Data, Link Intersects, Link Status, Linking Root Domains, Link Metrics, Top Pages Metrics, URL Metrics and Usage Data from over 36.5 Trillion different links.

This library is for anyone that is looking to build an SEO tool set for any purpose.

Dependencies

This library was written on PHP 7.2 and was written using file_get_contents so as not to incur the requirement of PHP-CURL. It does require PHP-JSON however.

Installation

Download the zip file from the repository and add Moz.php to your php applications path.

Retrieve an access_id and secret from Moz.com. If you dont' have one you can signup for a free account here: https://moz.com/products/api

Usage

Table of Contents


Brief Example of Use

<?php
// This require_once will vary depending on your php applications specific directory structure
require_once __DIR__ . DIRECTORY_SEPARATOR . 'Moz' . DIRECTORY_SEPARATOR . 'Moz.php';

//initialize the library
$moz = new Moz(your_access_id,your_secret);

//query some data
$result = $moz->urlMetrics("https://www.mediagiantdesign.com/");

//dump the result 
var_dump($result);

More detailed examples can be found here Moz API v2 Library for PHP.


License

(c) 2020 - Present, Rick Simnett [email protected]
License: MIT URL: https://www.mediagiantdesign.com/

mozapiv2's People

Contributors

mediagiant avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

mozapiv2's Issues

Getting error

I am getting the following error:

file_get_contents(https://lsapi.seomoz.com/v2/url_metrics): failed to open stream: HTTP request failed! HTTP/1.1 400 BAD REQUEST

at Moz.php:418

Moz::file_post_contents("https://lsapi.seomoz.com/v2/url_metrics", "{"targets":"www.bentoncourier.com","daily_history_deltas":[],"daily_history_values":[],"monthly_history_deltas":[],"monthly_history_values":[],"distributions":false}")

No response

Hello, I tried to use your lib but got no lucky... so I tried to do it directly.. with no lucky too... could you help me?

This is my code:

$url = 'https://lsapi.seomoz.com/v2/url_metrics';
$domains = json_encode(['targets' => ['moz.com']]);

$opts = ['http' =>
    [
        'method' => 'POST',
        'header' => 'Content-Type: application/x-www-form-urlencoded\r\n'.
            ("Authorization: Basic " . base64_encode("mozscape-XXXXXX:XXXXXX")),
        'content-length' => strlen($domains),
        'user-agent' => $_SERVER['HTTP_USER_AGENT'],
        'content' => $domains,
    ]
];

$context = stream_context_create($opts);
$result= file_get_contents($url, false, $context);

print_r($result);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.