The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Moz Tools
    4. How do I collect all links through the SEOMoz API?

    How do I collect all links through the SEOMoz API?

    Moz Tools
    5 2 485
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • destdigi
      destdigi last edited by

      How do I collect all links through the SEOMoz API?

      Yes, I know how to pull url metrics info but want to pull the inbound links only via php script w/out having to go to the OSE page to pull.

      any suggestions would be great!

      1 Reply Last reply Reply Quote 0
      • CaseyKluver
        CaseyKluver last edited by

        Please check out the authentication wiki page: http://apiwiki.seomoz.org/w/page/29574176/SignedAuthentication

        $objectURL = $domain_url;$accessID = "member-XXXXXXXXXXX";

        $secretKey = "XXXXXXXXXXXXXXX";

        $expires = mktime() + 300;

        // The request is good for the next 5 minutes, or 300 seconds from now.

        $stringToSign = $accessID."\n".$expires;

        // Get the "raw" or binary output of the hmac hash.

        $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);

        // We need to base64-encode it and then url-encode that.

        $urlSafeSignature = urlencode(base64_encode($binarySignature));

        $urlToFetch = "http://lsapi.seomoz.com/linkscape/links/".urlencode($objectURL)."?AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature."&SourceCols=26&&TargetCols=4&Scope=page_to_domain&Filter=follow&Sort=page_authority&Limit=25";

        // You don't have to use fopen and can't in some scenarios. CURL is a better choice for production.

        $handle = fopen($urlToFetch, "r");$links_contents = ''; while (!feof($handle)) {    $links_contents .= fread($handle, 8192);} fclose($handle);

        echo $links_contents;

        ?>

        Here is how we are pulling it in. Replace $accessID with your API code, you can sort and filter through the different link calls. Replace "Limit" with however much you want to pull in. The code will return a json response, from there you can parse the data however you want.

        I hope that helps!

        destdigi 1 Reply Last reply Reply Quote 1
        • destdigi
          destdigi @CaseyKluver last edited by

          thanks Casey,  let me have a run and let you know.

          cheers!

          CaseyKluver destdigi 2 Replies Last reply Reply Quote 0
          • CaseyKluver
            CaseyKluver @destdigi last edited by

            No problem, feel free to send me a private message if you need help with the code.

            1 Reply Last reply Reply Quote 0
            • destdigi
              destdigi @destdigi last edited by

              hey got it workin, I sent u a private message with a Q for a sort.

              cheers!

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • SEOMoz API not working for Scrapebox
                theLotter
                theLotter
                0
                3
                1.8k

              • SEOmoz Not Picking Up Links
                JacobEdward
                JacobEdward
                0
                6
                786

              • Why is SEOmoz link tagged with a (nofollow) for my site? I have tried to write a youmoz post a couple of times. But, I am just not an expert, that is why I am on SEOmoz.
                Smcnelley
                Smcnelley
                0
                4
                341

              • SEOMoz Link Analysis Not Updating?
                mad2k
                mad2k
                0
                3
                387

              • How good is Link Assistant Suite? and how good is the SEOmoz API?
                BenFox
                BenFox
                0
                2
                681

              • How come there are no links to my website according to SEOmoz Competive domain analysis, while in google webmaster i do see links.?
                lavellester
                lavellester
                0
                2
                587

              • 4XX links in SEOmoz
                KeriMorgret
                KeriMorgret
                0
                4
                467

              • Need a Google Doc That Imports List of Links From SEOMoz API
                ShaMenz
                ShaMenz
                0
                2
                705

              Get started with Moz Pro!

              Unlock the power of advanced SEO tools and data-driven insights.

              Start my free trial
              Products
              • Moz Pro
              • Moz Local
              • Moz API
              • Moz Data
              • STAT
              • Product Updates
              Moz Solutions
              • SMB Solutions
              • Agency Solutions
              • Enterprise Solutions
              • Digital Marketers
              Free SEO Tools
              • Domain Authority Checker
              • Link Explorer
              • Keyword Explorer
              • Competitive Research
              • Brand Authority Checker
              • Local Citation Checker
              • MozBar Extension
              • MozCast
              Resources
              • Blog
              • SEO Learning Center
              • Help Hub
              • Beginner's Guide to SEO
              • How-to Guides
              • Moz Academy
              • API Docs
              About Moz
              • About
              • Team
              • Careers
              • Contact
              Why Moz
              • Case Studies
              • Testimonials
              Get Involved
              • Become an Affiliate
              • MozCon
              • Webinars
              • Practical Marketer Series
              • MozPod
              Connect with us

              Contact the Help team

              Join our newsletter
              Moz logo
              © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
              • Accessibility
              • Terms of Use
              • Privacy